Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
|
4 |
+
model_name = "Salesforce/codegen-350M-mono"
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
|
8 |
+
def convert_rpg_code(prompt):
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_length=512)
|
11 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return result
|
13 |
+
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=convert_rpg_code,
|
16 |
+
inputs=gr.Textbox(label="RPG Fixed Form Code"),
|
17 |
+
outputs=gr.Textbox(label="Free Form RPG Code"),
|
18 |
+
allow_flagging="never"
|
19 |
+
)
|
20 |
+
|
21 |
+
iface.launch()
|
22 |
|
|
|
|