Spaces:
Runtime error
Runtime error
Commit
·
e850538
1
Parent(s):
05b3c71
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from PIL import Image
|
|
5 |
import pandas as pd
|
6 |
from lavis.models import load_model_and_preprocess
|
7 |
from lavis.processors import load_processor
|
8 |
-
from transformers import
|
9 |
|
10 |
# Load model and preprocessors for Image-Text Matching (LAVIS)
|
11 |
device = torch.device("cuda") if torch.cuda.is_available() else "cpu"
|
@@ -13,10 +13,9 @@ model_itm, vis_processors, text_processors = load_model_and_preprocess("blip2_im
|
|
13 |
|
14 |
# Load model and processor for Image Captioning (TextCaps)
|
15 |
model_caption = CLIPModel.from_pretrained("microsoft/git-large-r-textcaps")
|
16 |
-
processor_caption =
|
17 |
|
18 |
# List of statements for Image-Text Matching
|
19 |
-
# List of statements (Make sure to fully define this list with actual statements)
|
20 |
statements = [
|
21 |
"cartoon, figurine, or toy",
|
22 |
"appears to be for children",
|
@@ -68,5 +67,4 @@ def process_images_and_statements(image):
|
|
68 |
image_input = gr.inputs.Image()
|
69 |
output = gr.outputs.Textbox(label="Results")
|
70 |
|
71 |
-
iface = gr.Interface(fn=process_images_and_statements, inputs=image_input, outputs=output, title="
|
72 |
-
iface.launch()
|
|
|
5 |
import pandas as pd
|
6 |
from lavis.models import load_model_and_preprocess
|
7 |
from lavis.processors import load_processor
|
8 |
+
from transformers import CLIPTokenizerFast, CLIPModel # Import CLIPTokenizerFast
|
9 |
|
10 |
# Load model and preprocessors for Image-Text Matching (LAVIS)
|
11 |
device = torch.device("cuda") if torch.cuda.is_available() else "cpu"
|
|
|
13 |
|
14 |
# Load model and processor for Image Captioning (TextCaps)
|
15 |
model_caption = CLIPModel.from_pretrained("microsoft/git-large-r-textcaps")
|
16 |
+
processor_caption = CLIPTokenizerFast.from_pretrained("microsoft/git-large-r-textcaps", from_slow=True) # Convert tokenizer
|
17 |
|
18 |
# List of statements for Image-Text Matching
|
|
|
19 |
statements = [
|
20 |
"cartoon, figurine, or toy",
|
21 |
"appears to be for children",
|
|
|
67 |
image_input = gr.inputs.Image()
|
68 |
output = gr.outputs.Textbox(label="Results")
|
69 |
|
70 |
+
iface = gr.Interface(fn=process_images_and_statements, inputs=image_input, outputs=output, title="
|
|