Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import torch
|
| 3 |
from transformers import pipeline
|
| 4 |
-
import tensorflow as tf
|
| 5 |
-
import tf_keras
|
| 6 |
|
| 7 |
MODEL_ID = "Amitesh007/text_generation-finetuned-gpt2"
|
| 8 |
|
| 9 |
-
# Load model
|
| 10 |
generator = pipeline(
|
| 11 |
task="text-generation",
|
| 12 |
model=MODEL_ID,
|
| 13 |
-
framework="
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
def generate(text):
|
|
@@ -64,4 +63,6 @@ with gr.Blocks(title="GPT-2 Text Generator") as demo:
|
|
| 64 |
)
|
| 65 |
|
| 66 |
demo.queue(concurrency_count=2)
|
|
|
|
|
|
|
| 67 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
from transformers import pipeline
|
|
|
|
|
|
|
| 4 |
|
| 5 |
MODEL_ID = "Amitesh007/text_generation-finetuned-gpt2"
|
| 6 |
|
| 7 |
+
# ✅ Load PyTorch model explicitly
|
| 8 |
generator = pipeline(
|
| 9 |
task="text-generation",
|
| 10 |
model=MODEL_ID,
|
| 11 |
+
framework="pt", # 🔑 FIX
|
| 12 |
+
device=-1 # CPU (use 0 for GPU)
|
| 13 |
)
|
| 14 |
|
| 15 |
def generate(text):
|
|
|
|
| 63 |
)
|
| 64 |
|
| 65 |
demo.queue(concurrency_count=2)
|
| 66 |
+
demo.launch()
|
| 67 |
+
|
| 68 |
|