johnhelf commited on
Commit
c616e4b
·
1 Parent(s): 913237c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -26,7 +26,7 @@ def imGreyAlpha(im):
26
  return im2 # 返回图像
27
 
28
 
29
- def codeinterpreter(openai_key,prompt, files):
30
 
31
  fileList = []
32
  if files != None:
@@ -45,7 +45,10 @@ def codeinterpreter(openai_key,prompt, files):
45
  images = []
46
 
47
  for _file in response.files:
48
- images.append(_file.get_image())
 
 
 
49
 
50
  return [response.content,images]
51
 
@@ -56,7 +59,8 @@ with gr.Blocks() as app:
56
  with gr.Column():
57
  inp1=gr.Textbox(label="openai_key")
58
  inp2=gr.Textbox(label="prompt",info="input the prompt")
59
- inp3=gr.Files()
 
60
  btn = gr.Button(value="Submit")
61
  with gr.Column():
62
  out1=gr.Textbox(label="result")
@@ -73,7 +77,7 @@ with gr.Blocks() as app:
73
  btn10 = gr.Button(value="Submit")
74
  with gr.Column():
75
  out10=gr.Image(label="result")
76
- btn.click(codeinterpreter, inputs=[inp1,inp2,inp3], outputs=[out1,out2],api_name="getresult")
77
  btn10.click(imGreyAlpha,inputs=[inp10],outputs=[out10],api_name="imageFilter")
78
 
79
  app.launch()
 
26
  return im2 # 返回图像
27
 
28
 
29
+ def codeinterpreter(openai_key,prompt,filterBG, files):
30
 
31
  fileList = []
32
  if files != None:
 
45
  images = []
46
 
47
  for _file in response.files:
48
+ if filterBG:
49
+ images.append(imGreyAlpha(_file.get_image()))
50
+ else:
51
+ images.append(_file.get_image())
52
 
53
  return [response.content,images]
54
 
 
59
  with gr.Column():
60
  inp1=gr.Textbox(label="openai_key")
61
  inp2=gr.Textbox(label="prompt",info="input the prompt")
62
+ inp3=gr.Checkbox(label="do_filter_bg?", info="do background filter?")
63
+ inp4=gr.Files()
64
  btn = gr.Button(value="Submit")
65
  with gr.Column():
66
  out1=gr.Textbox(label="result")
 
77
  btn10 = gr.Button(value="Submit")
78
  with gr.Column():
79
  out10=gr.Image(label="result")
80
+ btn.click(codeinterpreter, inputs=[inp1,inp2,inp3,inp4], outputs=[out1,out2],api_name="getresult")
81
  btn10.click(imGreyAlpha,inputs=[inp10],outputs=[out10],api_name="imageFilter")
82
 
83
  app.launch()