Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
from gtts import gTTS
|
| 4 |
import tempfile
|
| 5 |
import os
|
|
@@ -17,7 +18,9 @@ def text2story(scenario):
|
|
| 17 |
"text-generation",
|
| 18 |
model="gpt2-medium",
|
| 19 |
trust_remote_code=True,
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
num_return_sequences=1
|
| 22 |
)
|
| 23 |
prompt = f"Create a children's story based on: {scenario}"
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
import torch
|
| 4 |
from gtts import gTTS
|
| 5 |
import tempfile
|
| 6 |
import os
|
|
|
|
| 18 |
"text-generation",
|
| 19 |
model="gpt2-medium",
|
| 20 |
trust_remote_code=True,
|
| 21 |
+
device_map="auto", # 必须添加
|
| 22 |
+
torch_dtype=torch.float16,
|
| 23 |
+
max_length=150,
|
| 24 |
num_return_sequences=1
|
| 25 |
)
|
| 26 |
prompt = f"Create a children's story based on: {scenario}"
|