Spaces:
Runtime error
Runtime error
Commit
·
fdb4240
1
Parent(s):
c12b438
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,12 +29,13 @@ model = AutoModelForCausalLM.from_pretrained(model_path)
|
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 30 |
|
| 31 |
# Example usage
|
| 32 |
-
input_text = "Once upon a time"
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
|
| 40 |
text_generation_interface = gr.Interface(
|
|
|
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 30 |
|
| 31 |
# Example usage
|
| 32 |
+
# input_text = "Once upon a time"
|
| 33 |
+
def generated_text(input_text):
|
| 34 |
+
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
|
| 35 |
+
output = model.generate(input_ids, max_length=50, num_return_sequences=1)
|
| 36 |
+
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 37 |
+
return generated_text
|
| 38 |
+
# print(generated_text)
|
| 39 |
|
| 40 |
|
| 41 |
text_generation_interface = gr.Interface(
|