Spaces:
Build error
Build error
Yair
commited on
Commit
•
6437a53
1
Parent(s):
7dbd807
update app.py
Browse files- app.py +6 -1
- examples/download.jpg +0 -0
- examples/img1.jpg +0 -0
- examples/img2.jpg +0 -0
- examples/img3.jpg +0 -0
- examples/img4.jpg +0 -0
- examples/img5.jpg +0 -0
- examples/img6.jpg +0 -0
- examples/img7.jpg +0 -0
- examples/img8.jpg +0 -0
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
-
import gradio as gr
|
2 |
import os
|
|
|
|
|
3 |
from transformers import VisionEncoderDecoderModel, AutoFeatureExtractor, AutoTokenizer
|
4 |
|
5 |
|
@@ -18,10 +19,14 @@ def create_caption_transformer(img):
|
|
18 |
return caption_text
|
19 |
|
20 |
|
|
|
|
|
|
|
21 |
model = VisionEncoderDecoderModel.from_pretrained(os.getcwd()).to('cpu')
|
22 |
feature_extractor = AutoFeatureExtractor.from_pretrained('google/vit-base-patch16-224-in21k')
|
23 |
tokenizer = AutoTokenizer.from_pretrained('gpt2')
|
24 |
iface = gr.Interface(fn=create_caption_transformer,
|
25 |
inputs="image",
|
26 |
outputs='text',
|
|
|
27 |
).launch(share=True)
|
|
|
|
|
1 |
import os
|
2 |
+
import torch
|
3 |
+
import gradio as gr
|
4 |
from transformers import VisionEncoderDecoderModel, AutoFeatureExtractor, AutoTokenizer
|
5 |
|
6 |
|
|
|
19 |
return caption_text
|
20 |
|
21 |
|
22 |
+
IMAGES_EXAMPLES_FOLDER = 'examples/'
|
23 |
+
images = os.listdir(IMAGES_EXAMPLES_FOLDER)
|
24 |
+
IMAGES_EXAMPLES = [IMAGES_EXAMPLES_FOLDER + img for img in images]
|
25 |
model = VisionEncoderDecoderModel.from_pretrained(os.getcwd()).to('cpu')
|
26 |
feature_extractor = AutoFeatureExtractor.from_pretrained('google/vit-base-patch16-224-in21k')
|
27 |
tokenizer = AutoTokenizer.from_pretrained('gpt2')
|
28 |
iface = gr.Interface(fn=create_caption_transformer,
|
29 |
inputs="image",
|
30 |
outputs='text',
|
31 |
+
examples=IMAGES_EXAMPLES
|
32 |
).launch(share=True)
|
examples/download.jpg
ADDED
examples/img1.jpg
ADDED
examples/img2.jpg
ADDED
examples/img3.jpg
ADDED
examples/img4.jpg
ADDED
examples/img5.jpg
ADDED
examples/img6.jpg
ADDED
examples/img7.jpg
ADDED
examples/img8.jpg
ADDED