Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,8 @@ def predict(image,max_length=64, num_beams=4):
|
|
| 20 |
clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
|
| 21 |
caption_ids = model.generate(image, max_length = max_length)[0]
|
| 22 |
caption_text = clean_text(tokenizer.decode(caption_ids))
|
| 23 |
-
caption_text2 = generate_captions(image)
|
| 24 |
-
return caption_text
|
| 25 |
|
| 26 |
blip_processor_large = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 27 |
blip_model_large = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
|
@@ -60,7 +60,6 @@ input = gr.inputs.Image(label="Upload your Image", type = 'pil', optional=True)
|
|
| 60 |
#Two output boxes
|
| 61 |
|
| 62 |
output_1 = gr.outputs.Textbox(type="text",label="Caption - 1")
|
| 63 |
-
output_2 = gr.outputs.Textbox(type="text",label="Caption - 2")
|
| 64 |
examples = [f"example{i}.png" for i in range(1,4)]
|
| 65 |
|
| 66 |
description= "Image caption Generator"
|
|
@@ -72,7 +71,7 @@ interface = gr.Interface(
|
|
| 72 |
fn=predict,
|
| 73 |
inputs = input,
|
| 74 |
theme="grass",
|
| 75 |
-
outputs =
|
| 76 |
examples = examples,
|
| 77 |
title=title,
|
| 78 |
description=description,
|
|
|
|
| 20 |
clean_text = lambda x: x.replace('<|endoftext|>','').split('\n')[0]
|
| 21 |
caption_ids = model.generate(image, max_length = max_length)[0]
|
| 22 |
caption_text = clean_text(tokenizer.decode(caption_ids))
|
| 23 |
+
#caption_text2 = generate_captions(image)
|
| 24 |
+
return caption_text
|
| 25 |
|
| 26 |
blip_processor_large = AutoProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
|
| 27 |
blip_model_large = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
|
|
|
| 60 |
#Two output boxes
|
| 61 |
|
| 62 |
output_1 = gr.outputs.Textbox(type="text",label="Caption - 1")
|
|
|
|
| 63 |
examples = [f"example{i}.png" for i in range(1,4)]
|
| 64 |
|
| 65 |
description= "Image caption Generator"
|
|
|
|
| 71 |
fn=predict,
|
| 72 |
inputs = input,
|
| 73 |
theme="grass",
|
| 74 |
+
outputs = output_1,
|
| 75 |
examples = examples,
|
| 76 |
title=title,
|
| 77 |
description=description,
|