Kosuke-Yamada commited on
Commit
9c4906e
•
1 Parent(s): 11f3589

change file

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -11,8 +11,7 @@ import difflib
11
  import io
12
  import os
13
 
14
- api_key = os.getenvs('OPENAI_API_KEY')
15
- client = OpenAI(api_key=api_key)
16
 
17
  def generate_image(text):
18
  image_path = f"/content/images/{text}.png"
@@ -97,7 +96,7 @@ def update_question(selected_option):
97
  else:
98
  return "/content/images/abc.png"
99
 
100
- def main(image, text, option):
101
  ori_text = update_question(option).split("/")[-1].split(".png")[0]
102
  image_path = generate_image(text)
103
  score = calulate_similarity_score(ori_text, text)
@@ -128,6 +127,6 @@ with gr.Blocks() as demo:
128
  output_score = gr.components.Textbox(lines=1, label="スコア")
129
  output_hint_text = gr.components.Textbox(lines=1, label="ヒント")
130
 
131
- submit_button.click(main, inputs=[output_title_image, input_text, selected_option], outputs=[output_image, output_score, output_hint_text])
132
  demo.launch(server_port=8892)
133
  demo.launch()
 
11
  import io
12
  import os
13
 
14
+ client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
 
15
 
16
  def generate_image(text):
17
  image_path = f"/content/images/{text}.png"
 
96
  else:
97
  return "/content/images/abc.png"
98
 
99
+ def main(text, option):
100
  ori_text = update_question(option).split("/")[-1].split(".png")[0]
101
  image_path = generate_image(text)
102
  score = calulate_similarity_score(ori_text, text)
 
127
  output_score = gr.components.Textbox(lines=1, label="スコア")
128
  output_hint_text = gr.components.Textbox(lines=1, label="ヒント")
129
 
130
+ submit_button.click(main, inputs=[input_text, selected_option], outputs=[output_image, output_score, output_hint_text])
131
  demo.launch(server_port=8892)
132
  demo.launch()