Eason918 commited on
Commit
f6a48f5
·
verified ·
1 Parent(s): ee966b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -17,7 +17,7 @@ def img2text(image_path):
17
  # 文字 → 故事(生成完整故事)
18
  def text2story(text):
19
  prompt = f"Write a fun and magical children's story based on this idea: {text}.\n\nOnce upon a time..."
20
- story = story_generator(prompt, max_length=250, do_sample=True, temperature=0.8, top_p=0.9, repetition_penalty=1.2, truncation=True)[0]['generated_text']
21
  return story
22
 
23
  # 故事 → 語音(TTS)
@@ -50,7 +50,7 @@ if uploaded_file:
50
 
51
  # 讀取並顯示圖片
52
  image = Image.open(image_path)
53
- st.image(image, caption="Uploaded Image", use_column_width=True)
54
 
55
  # 生成圖片描述
56
  st.text("🔍 Generating image caption...")
 
17
  # 文字 → 故事(生成完整故事)
18
  def text2story(text):
19
  prompt = f"Write a fun and magical children's story based on this idea: {text}.\n\nOnce upon a time..."
20
+ story = story_generator(prompt, max_length=250, do_sample=True, temperature=0.8, top_p=0.9, repetition_penalty=1.2)[0]['generated_text']
21
  return story
22
 
23
  # 故事 → 語音(TTS)
 
50
 
51
  # 讀取並顯示圖片
52
  image = Image.open(image_path)
53
+ st.image(image, caption="Uploaded Image", use_container_width=True)
54
 
55
  # 生成圖片描述
56
  st.text("🔍 Generating image caption...")