Evaaaaa06 commited on
Commit
7cf743a
·
verified ·
1 Parent(s): dede85f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -4
main.py CHANGED
@@ -198,10 +198,12 @@ def handle_image_message(event):
198
  line_bot_api.reply_message(event.reply_token, TextSendMessage(text="圖片生成中~ 請稍候.....✨"))
199
  client = ImgurClient(client_id, client_secret, access_token, refresh_token)
200
 
201
- # 使用翻譯任務
202
- translator = pipeline("translation", model='Helsinki-NLP/opus-mt-zh-en')
203
- prompt = prompt[0]['translation_text']
204
- image_binary = generate_image_hf(prompt)
 
 
205
 
206
  if image_binary:
207
  album = "nvsYwgq"
 
198
  line_bot_api.reply_message(event.reply_token, TextSendMessage(text="圖片生成中~ 請稍候.....✨"))
199
  client = ImgurClient(client_id, client_secret, access_token, refresh_token)
200
 
201
+ translator = pipeline("translation", model='Helsinki-NLP/opus-mt-zh-en')
202
+ translation = translator(prompt_zh)
203
+ prompt_en = translation[0]['translation_text']
204
+
205
+ # 生成圖片
206
+ image_binary = generate_image_hf(prompt_en)
207
 
208
  if image_binary:
209
  album = "nvsYwgq"