Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,8 +9,13 @@ import gradio as gr
|
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
-
model = M2M100ForConditionalGeneration.from_pretrained("facebook/m2m100_418M")
|
| 13 |
-
tokenizer = M2M100Tokenizer.from_pretrained("facebook/m2m100_418M")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-base-patch32")
|
| 16 |
images="dog.jpg"
|
|
@@ -29,10 +34,7 @@ def shot(image, labels_text):
|
|
| 29 |
candidate_labels=labels,
|
| 30 |
hypothesis_template= "This is a photo of a {}")
|
| 31 |
|
| 32 |
-
|
| 33 |
-
encodedText = tokenizer(labels_text, return_tensors="pt")
|
| 34 |
-
generatedTokens = model.generate(**encodedText, forced_bos_token_id=tokenizer.get_lang_id("ru"))
|
| 35 |
-
return tokenizer.batch_decode(generatedTokens, skip_special_tokens=True)[0], {dic["label"]: dic["score"] for dic in res}
|
| 36 |
|
| 37 |
|
| 38 |
iface = gr.Interface(shot,
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
+
#model = M2M100ForConditionalGeneration.from_pretrained("facebook/m2m100_418M")
|
| 13 |
+
#tokenizer = M2M100Tokenizer.from_pretrained("facebook/m2m100_418M")
|
| 14 |
+
#tokenizer.src_lang = "en"
|
| 15 |
+
#encodedText = tokenizer(labels_text, return_tensors="pt")
|
| 16 |
+
#generatedTokens = model.generate(**encodedText, forced_bos_token_id=tokenizer.get_lang_id("ru"))
|
| 17 |
+
#return tokenizer.batch_decode(generatedTokens, skip_special_tokens=True)[0]
|
| 18 |
+
|
| 19 |
|
| 20 |
pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-base-patch32")
|
| 21 |
images="dog.jpg"
|
|
|
|
| 34 |
candidate_labels=labels,
|
| 35 |
hypothesis_template= "This is a photo of a {}")
|
| 36 |
|
| 37 |
+
return {dic["label"]: dic["score"] for dic in res}
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
iface = gr.Interface(shot,
|