Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -55,9 +55,13 @@ device='cpu'
|
|
55 |
encoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
56 |
decoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
57 |
model_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
|
|
58 |
feature_extractor = ViTFeatureExtractor.from_pretrained(encoder_checkpoint)
|
59 |
-
|
|
|
|
|
60 |
model = VisionEncoderDecoderModel.from_pretrained(model_checkpoint).to(device)
|
|
|
61 |
|
62 |
|
63 |
def predict(image,max_length=64, num_beams=4):
|
@@ -69,13 +73,13 @@ def predict(image,max_length=64, num_beams=4):
|
|
69 |
return caption_text
|
70 |
|
71 |
|
72 |
-
|
73 |
input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
|
74 |
output = gr.outputs.Textbox(type="auto",label="Captions")
|
75 |
examples = [f"example{i}.jpg" for i in range(1,7)]
|
76 |
-
|
77 |
title = "Image Captioning "
|
78 |
-
description = "
|
79 |
interface = gr.Interface(
|
80 |
|
81 |
fn=predict,
|
|
|
55 |
encoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
56 |
decoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
57 |
model_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
58 |
+
print("------------------------- 1 -------------------------\n")
|
59 |
feature_extractor = ViTFeatureExtractor.from_pretrained(encoder_checkpoint)
|
60 |
+
print("------------------------- 2 -------------------------\n")
|
61 |
+
tokenizer = AutoTokenizer.from_pretrained(decoder_checkpoint
|
62 |
+
print("------------------------- 3 -------------------------\n")
|
63 |
model = VisionEncoderDecoderModel.from_pretrained(model_checkpoint).to(device)
|
64 |
+
print("------------------------- 4 -------------------------\n")
|
65 |
|
66 |
|
67 |
def predict(image,max_length=64, num_beams=4):
|
|
|
73 |
return caption_text
|
74 |
|
75 |
|
76 |
+
print("------------------------- 5 -------------------------\n")
|
77 |
input = gr.inputs.Image(label="Upload any Image", type = 'pil', optional=True)
|
78 |
output = gr.outputs.Textbox(type="auto",label="Captions")
|
79 |
examples = [f"example{i}.jpg" for i in range(1,7)]
|
80 |
+
print("------------------------- 6 -------------------------\n")
|
81 |
title = "Image Captioning "
|
82 |
+
description = "NTT Data"
|
83 |
interface = gr.Interface(
|
84 |
|
85 |
fn=predict,
|