Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def reverse_text(input_text):
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
temperature=0.7
|
| 15 |
-
)
|
| 16 |
-
return response
|
| 17 |
-
except Exception as e:
|
| 18 |
-
return f"Error: {str(e)}"
|
| 19 |
|
|
|
|
| 20 |
demo = gr.Interface(
|
| 21 |
fn=reverse_text,
|
| 22 |
inputs=gr.Textbox(label="Input Text"),
|
| 23 |
-
outputs=gr.Textbox(label="
|
| 24 |
-
title="Reverse Text Model Demo"
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 3 |
|
| 4 |
+
# Load your model
|
| 5 |
+
model_name = "loocorez/reverse-text-warmup"
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 8 |
|
| 9 |
def reverse_text(input_text):
|
| 10 |
+
# Add your model inference logic here
|
| 11 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 12 |
+
outputs = model.generate(**inputs, max_length=100)
|
| 13 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 14 |
+
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Create Gradio interface
|
| 17 |
demo = gr.Interface(
|
| 18 |
fn=reverse_text,
|
| 19 |
inputs=gr.Textbox(label="Input Text"),
|
| 20 |
+
outputs=gr.Textbox(label="Reversed Text"),
|
| 21 |
+
title="Reverse Text Model Demo",
|
| 22 |
+
description="Test the reverse-text-warmup model"
|
| 23 |
)
|
| 24 |
|
| 25 |
demo.launch()
|