Spaces:
Sleeping
Sleeping
Commit
·
02ca452
1
Parent(s):
4bf6497
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,38 +1,31 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
"generator",
|
| 8 |
-
pretrained=True,
|
| 9 |
-
progress=False
|
| 10 |
-
)
|
| 11 |
-
model1 = torch.hub.load("AK391/animegan2-pytorch:main", "generator", pretrained="face_paint_512_v1")
|
| 12 |
-
face2paint = torch.hub.load(
|
| 13 |
-
'AK391/animegan2-pytorch:main', 'face2paint',
|
| 14 |
-
size=512,side_by_side=False
|
| 15 |
-
)
|
| 16 |
|
| 17 |
def inference(img, ver):
|
| 18 |
-
if ver ==
|
| 19 |
-
out =
|
| 20 |
else:
|
| 21 |
-
out =
|
| 22 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
demo = gr.Interface(
|
| 30 |
-
fn=
|
| 31 |
-
inputs=[gr.inputs.
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
examples=examples)
|
| 37 |
|
| 38 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
|
|
|
| 3 |
|
| 4 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-large")
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-large")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def inference(img, ver):
|
| 8 |
+
if ver == "Hidden Identity 1":
|
| 9 |
+
out = "Michael Jackson"
|
| 10 |
else:
|
| 11 |
+
out = "Brad Pitt"
|
| 12 |
return out
|
| 13 |
+
|
| 14 |
+
def generate(text,guess):
|
| 15 |
+
inputs = tokenizer(f"Answer with yes or no the following question about {guess}: {text}?", return_tensors="pt")
|
| 16 |
+
return model.generate(**inputs)[0]
|
| 17 |
|
| 18 |
+
examples = [
|
| 19 |
+
["Is it dead?"],
|
| 20 |
+
["Is it a female?"],
|
| 21 |
+
]
|
| 22 |
|
| 23 |
demo = gr.Interface(
|
| 24 |
+
fn=generate,
|
| 25 |
+
inputs=[gr.inputs.Textbox(lines=5, label="Input Text"),
|
| 26 |
+
gr.inputs.Radio("Hidden Identity 1", type="value", default='Hidden Identity 1', label='Hidden identity')],
|
| 27 |
+
outputs=gr.outputs.Textbox(label="Generated Text"),
|
| 28 |
+
examples=examples
|
| 29 |
+
)
|
|
|
|
| 30 |
|
| 31 |
demo.launch()
|