Kaushik Bar
commited on
Commit
·
7bbe89d
1
Parent(s):
b5bfdc5
first commit
Browse files
app.py
CHANGED
|
@@ -56,17 +56,17 @@ def prep_examples():
|
|
| 56 |
example_labels11 = "bhalo;;kharap"
|
| 57 |
|
| 58 |
examples = [
|
| 59 |
-
[example_text1, example_labels1],
|
| 60 |
-
[example_text2, example_labels2],
|
| 61 |
-
[example_text3, example_labels3],
|
| 62 |
-
[example_text4, example_labels4],
|
| 63 |
-
[example_text5, example_labels5],
|
| 64 |
-
[example_text6, example_labels6],
|
| 65 |
-
[example_text7, example_labels7],
|
| 66 |
-
[example_text8, example_labels8],
|
| 67 |
-
[example_text9, example_labels9],
|
| 68 |
-
[example_text10, example_labels10],
|
| 69 |
-
[example_text11, example_labels11]]
|
| 70 |
|
| 71 |
return examples
|
| 72 |
|
|
@@ -92,10 +92,10 @@ def sequence_to_classify(text, labels, hypothesis_template):
|
|
| 92 |
else:
|
| 93 |
model = model_multi
|
| 94 |
|
| 95 |
-
if hypothesis_template:
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
|
| 100 |
if str(type(model)) == "<class 'clip.model.CLIP'>":
|
| 101 |
text_tokens = clip.tokenize(text)
|
|
@@ -151,7 +151,7 @@ iface = gr.Interface(
|
|
| 151 |
label="Please enter the candidate labels (separated by 2 consecutive semicolons)...",
|
| 152 |
placeholder="Labels here separated by ;;"),
|
| 153 |
gr.inputs.Textbox(lines=2,
|
| 154 |
-
label="Please enter the text for hypothesis template(optional)...",
|
| 155 |
placeholder="Text here...")],
|
| 156 |
outputs=gr.outputs.Label(num_top_classes=5),
|
| 157 |
#interpretation="default",
|
|
|
|
| 56 |
example_labels11 = "bhalo;;kharap"
|
| 57 |
|
| 58 |
examples = [
|
| 59 |
+
[example_text1, example_labels1, ""],
|
| 60 |
+
[example_text2, example_labels2, ""],
|
| 61 |
+
[example_text3, example_labels3, ""],
|
| 62 |
+
[example_text4, example_labels4, "The sentiment expressed here is {}."],
|
| 63 |
+
[example_text5, example_labels5, ""],
|
| 64 |
+
[example_text6, example_labels6, ""],
|
| 65 |
+
[example_text7, example_labels7, ""],
|
| 66 |
+
[example_text8, example_labels8, ""],
|
| 67 |
+
[example_text9, example_labels9, ""],
|
| 68 |
+
[example_text10, example_labels10, ""],
|
| 69 |
+
[example_text11, example_labels11, ""]]
|
| 70 |
|
| 71 |
return examples
|
| 72 |
|
|
|
|
| 92 |
else:
|
| 93 |
model = model_multi
|
| 94 |
|
| 95 |
+
if hypothesis_template == None:
|
| 96 |
+
hypothesis_template = "{}"
|
| 97 |
+
print("I'm here")
|
| 98 |
+
labels = [hypothesis_template.format(label) for label in labels.split(";;")]
|
| 99 |
|
| 100 |
if str(type(model)) == "<class 'clip.model.CLIP'>":
|
| 101 |
text_tokens = clip.tokenize(text)
|
|
|
|
| 151 |
label="Please enter the candidate labels (separated by 2 consecutive semicolons)...",
|
| 152 |
placeholder="Labels here separated by ;;"),
|
| 153 |
gr.inputs.Textbox(lines=2,
|
| 154 |
+
label="Please enter the text for hypothesis template (optional)...",
|
| 155 |
placeholder="Text here...")],
|
| 156 |
outputs=gr.outputs.Label(num_top_classes=5),
|
| 157 |
#interpretation="default",
|