Spaces:
Running
on
Zero
Running
on
Zero
update
Browse files
app.py
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
import spaces
|
2 |
from diffusers import DiffusionPipeline
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
5 |
pipe.to('cuda')
|
6 |
|
7 |
@spaces.GPU
|
8 |
def generate(prompt):
|
9 |
-
|
|
|
10 |
|
11 |
gr.Interface(
|
12 |
fn=generate,
|
13 |
inputs=gr.Text(),
|
14 |
-
outputs=gr.
|
15 |
).launch()
|
|
|
1 |
import spaces
|
2 |
from diffusers import DiffusionPipeline
|
3 |
|
4 |
+
import torch
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
pipe = pipeline("text-generation", "meta-llama/Meta-Llama-3-8B-Instruct", torch_dtype=torch.bfloat16, device_map="auto")
|
8 |
+
response = pipe(chat, max_new_tokens=512)
|
9 |
+
|
10 |
pipe.to('cuda')
|
11 |
|
12 |
@spaces.GPU
|
13 |
def generate(prompt):
|
14 |
+
r = response[0]['generated_text'][-1]['content']
|
15 |
+
return r
|
16 |
|
17 |
gr.Interface(
|
18 |
fn=generate,
|
19 |
inputs=gr.Text(),
|
20 |
+
outputs=gr.Text(),
|
21 |
).launch()
|