Spaces:
Build error
Build error
Added rap distil model
Browse files- app.py +28 -3
- requirements.txt +3 -0
app.py
CHANGED
|
@@ -1,7 +1,32 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline, set_seed
|
| 3 |
|
| 4 |
+
chef = pipeline("text-generation", "nschenone/rap-distil")
|
|
|
|
| 5 |
|
| 6 |
+
def generate(text):
|
| 7 |
+
max_length: int = 100
|
| 8 |
+
num_beams: int = 5
|
| 9 |
+
num_return_sequences: int = 1
|
| 10 |
+
no_repeat_ngram_size: int = 3
|
| 11 |
+
early_stopping: bool = True
|
| 12 |
+
skip_special_tokens: bool = True
|
| 13 |
+
temperature: float = 1.5
|
| 14 |
+
|
| 15 |
+
set_seed(0)
|
| 16 |
+
|
| 17 |
+
generated = chef(
|
| 18 |
+
text_inputs=text,
|
| 19 |
+
max_length=max_length,
|
| 20 |
+
num_beams=num_beams,
|
| 21 |
+
num_return_sequences=num_return_sequences,
|
| 22 |
+
no_repeat_ngram_size=no_repeat_ngram_size,
|
| 23 |
+
early_stopping=early_stopping,
|
| 24 |
+
skip_special_tokens=skip_special_tokens,
|
| 25 |
+
temperature=temperature
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
return [i["generated_text"] for i in generated]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
iface = gr.Interface(fn=generate, inputs="text", outputs="text")
|
| 32 |
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers==4.11.3
|
| 2 |
+
torch==1.12.1
|
| 3 |
+
gradio==3.2
|