Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 8 |
|
| 9 |
def reverse_text(input_text):
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="
|
| 21 |
-
title="Reverse Text Model Demo"
|
| 22 |
-
description="Test the reverse-text-warmup model"
|
| 23 |
)
|
| 24 |
|
| 25 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# Use Inference API instead of loading model locally
|
| 5 |
+
client = InferenceClient("loocorez/reverse-text-warmup")
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def reverse_text(input_text):
|
| 8 |
+
try:
|
| 9 |
+
# Use the inference API
|
| 10 |
+
response = client.text_generation(
|
| 11 |
+
input_text,
|
| 12 |
+
max_new_tokens=100,
|
| 13 |
+
temperature=0.7
|
| 14 |
+
)
|
| 15 |
+
return response
|
| 16 |
+
except Exception as e:
|
| 17 |
+
return f"Error: {str(e)}"
|
| 18 |
|
|
|
|
| 19 |
demo = gr.Interface(
|
| 20 |
fn=reverse_text,
|
| 21 |
inputs=gr.Textbox(label="Input Text"),
|
| 22 |
+
outputs=gr.Textbox(label="Output"),
|
| 23 |
+
title="Reverse Text Model Demo"
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
demo.launch()
|