Spaces:
Sleeping
Sleeping
Commit
·
4fb5fb4
1
Parent(s):
cb39169
init
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
# Import necessary libraries
|
2 |
import torch
|
|
|
3 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM, pipeline
|
4 |
import gradio as gr
|
5 |
|
@@ -18,6 +19,7 @@ if torch.cuda.is_available():
|
|
18 |
text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
19 |
|
20 |
# Function to generate text
|
|
|
21 |
def generate_text(input_text):
|
22 |
output = text_generator(input_text, max_new_tokens=25, add_special_tokens=False, do_sample=True)
|
23 |
return output[0]['generated_text']
|
|
|
1 |
# Import necessary libraries
|
2 |
import torch
|
3 |
+
import spaces
|
4 |
from transformers import AutoTokenizer, AutoConfig, AutoModelForCausalLM, pipeline
|
5 |
import gradio as gr
|
6 |
|
|
|
19 |
text_generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
20 |
|
21 |
# Function to generate text
|
22 |
+
@spaces.GPU
|
23 |
def generate_text(input_text):
|
24 |
output = text_generator(input_text, max_new_tokens=25, add_special_tokens=False, do_sample=True)
|
25 |
return output[0]['generated_text']
|