zanemotiwala
commited on
Commit
•
f9c45b9
1
Parent(s):
0e3c47c
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,6 @@ import gradio as gr
|
|
2 |
from transformers import AutoTokenizer, VisionEncoderDecoderModel, ViTImageProcessor, ViTForImageClassification
|
3 |
import torch
|
4 |
|
5 |
-
description = "Simple Image Captioning & Recognition App"
|
6 |
-
title = "This app allows users to upload an image to be transcribed into text and for classification. It can take a couple minutes for the image to text for high quality images."
|
7 |
-
|
8 |
-
|
9 |
# Initialize device and models for captioning
|
10 |
device = 'cpu'
|
11 |
encoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
@@ -43,6 +39,10 @@ def classify_image(image):
|
|
43 |
# Set up Gradio interface
|
44 |
title = "Image Captioning and Recognition"
|
45 |
with gr.Blocks(title=title) as demo:
|
|
|
|
|
|
|
|
|
46 |
with gr.Column():
|
47 |
image_input = gr.Image(label="Upload any Image", type='pil')
|
48 |
get_caption_btn = gr.Button("Get Caption")
|
|
|
2 |
from transformers import AutoTokenizer, VisionEncoderDecoderModel, ViTImageProcessor, ViTForImageClassification
|
3 |
import torch
|
4 |
|
|
|
|
|
|
|
|
|
5 |
# Initialize device and models for captioning
|
6 |
device = 'cpu'
|
7 |
encoder_checkpoint = "nlpconnect/vit-gpt2-image-captioning"
|
|
|
39 |
# Set up Gradio interface
|
40 |
title = "Image Captioning and Recognition"
|
41 |
with gr.Blocks(title=title) as demo:
|
42 |
+
with gr.Row():
|
43 |
+
gr.Markdown("# Simple Image Caption & Image Recognition App")
|
44 |
+
with gr.Row():
|
45 |
+
gr.Markdown("### This app allows you to upload an image and see it's caption and classification.")
|
46 |
with gr.Column():
|
47 |
image_input = gr.Image(label="Upload any Image", type='pil')
|
48 |
get_caption_btn = gr.Button("Get Caption")
|