Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,13 @@ import gradio as gr
|
|
| 2 |
import spaces
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def generate_response(prompt):
|
| 10 |
output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
|
| 11 |
return output[0]['generated_text']
|
| 12 |
|
| 13 |
-
# api_name hatasını sildik, en sade haliyle bırakıyoruz
|
| 14 |
demo = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 15 |
demo.launch()
|
|
|
|
| 2 |
import spaces
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
# device=0 ile modele GPU beklemesini söylüyoruz. ZeroGPU arka planda bunu yönetecek.
|
| 6 |
+
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct", device=0)
|
| 7 |
|
| 8 |
@spaces.GPU
|
| 9 |
def generate_response(prompt):
|
| 10 |
output = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7)
|
| 11 |
return output[0]['generated_text']
|
| 12 |
|
|
|
|
| 13 |
demo = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 14 |
demo.launch()
|