Spaces:
Runtime error
Runtime error
autonomous019
commited on
Commit
•
808eb6f
1
Parent(s):
9f74712
bug fixing
Browse files
app.py
CHANGED
@@ -59,19 +59,20 @@ def self_caption(image):
|
|
59 |
print(pixel_values)
|
60 |
# autoregressively generate text (using beam search or other decoding strategy)
|
61 |
generated_ids = model2.generate(pixel_values, max_length=16, num_beams=4, return_dict_in_generate=True)
|
|
|
|
|
62 |
# decode into text
|
63 |
preds = tokenizer.batch_decode(generated_ids[0], skip_special_tokens=True)
|
64 |
-
|
65 |
-
|
|
|
|
|
66 |
preds = [pred.strip() for pred in preds]
|
67 |
print("Predictions")
|
68 |
print(preds)
|
69 |
-
|
70 |
-
pred_output = preds
|
71 |
-
#for prediction in preds:
|
72 |
-
# pred_output[predicted_label] = prediction
|
73 |
|
74 |
-
return
|
75 |
|
76 |
def classify_image(image):
|
77 |
results = image_pipe(image)
|
@@ -108,7 +109,10 @@ print("img_info2")
|
|
108 |
img_info2 = gr.Interface(
|
109 |
fn=self_caption,
|
110 |
inputs=image,
|
111 |
-
outputs=label,
|
|
|
|
|
|
|
112 |
)
|
113 |
print("running parallel call")
|
114 |
Parallel(
|
|
|
59 |
print(pixel_values)
|
60 |
# autoregressively generate text (using beam search or other decoding strategy)
|
61 |
generated_ids = model2.generate(pixel_values, max_length=16, num_beams=4, return_dict_in_generate=True)
|
62 |
+
|
63 |
+
|
64 |
# decode into text
|
65 |
preds = tokenizer.batch_decode(generated_ids[0], skip_special_tokens=True)
|
66 |
+
#generated_sentences = tokenizer.batch_decode(encoder_outputs, skip_special_tokens=True)
|
67 |
+
|
68 |
+
#return(generated_sentences[0].split('.')[0])
|
69 |
+
|
70 |
preds = [pred.strip() for pred in preds]
|
71 |
print("Predictions")
|
72 |
print(preds)
|
73 |
+
|
|
|
|
|
|
|
74 |
|
75 |
+
return(preds[0].split('.')[0])
|
76 |
|
77 |
def classify_image(image):
|
78 |
results = image_pipe(image)
|
|
|
109 |
img_info2 = gr.Interface(
|
110 |
fn=self_caption,
|
111 |
inputs=image,
|
112 |
+
#outputs=label,
|
113 |
+
outputs = [
|
114 |
+
gr.outputs.Textbox(label = 'Caption')
|
115 |
+
],
|
116 |
)
|
117 |
print("running parallel call")
|
118 |
Parallel(
|