cai-qi commited on
Commit
5650c4a
·
verified ·
1 Parent(s): 4bdcd90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -12,7 +12,6 @@ import requests
12
  import gradio as gr
13
  import requests
14
  from PIL import Image, PngImagePlugin
15
-
16
  # Set up logging
17
  logging.basicConfig(
18
  level=logging.INFO,
@@ -94,9 +93,9 @@ Output Format:
94
  * Do not include any other explanations, comments, introductory phrases, labels (like "Line 1:"), or formatting.
95
  * Your output should be in English.
96
 
97
- Line 1: [Description of the Source Image]
98
- Line 2: [The specific, single-line editing instruction based on the Source Instruction and Source Image context]
99
- Line 3: [Description of the Imagined Target Image based on Lines 1 & 2]
100
 
101
  Now, please generate the three-line output based on the Source Image and the Source Instruction: {source_instruction}
102
  """
@@ -116,9 +115,16 @@ def filter_response(src_instruction):
116
  except:
117
  return ""
118
 
 
 
 
 
 
 
 
119
  def refine_instruction(src_image, src_instruction):
120
  MAX_TOKENS_RESPONSE = 500 # Limit response tokens as output format is structured
121
- client = OpenAI()
122
  src_image = src_image.convert("RGB")
123
  src_image_buffer = io.BytesIO()
124
  src_image.save(src_image_buffer, format="JPEG")
 
12
  import gradio as gr
13
  import requests
14
  from PIL import Image, PngImagePlugin
 
15
  # Set up logging
16
  logging.basicConfig(
17
  level=logging.INFO,
 
93
  * Do not include any other explanations, comments, introductory phrases, labels (like "Line 1:"), or formatting.
94
  * Your output should be in English.
95
 
96
+ [Description of the Source Image]
97
+ [The specific, single-line editing instruction based on the Source Instruction and Source Image context]
98
+ [Description of the Imagined Target Image based on Lines 1 & 2]
99
 
100
  Now, please generate the three-line output based on the Source Image and the Source Instruction: {source_instruction}
101
  """
 
115
  except:
116
  return ""
117
 
118
+ import httpx
119
+ # Create a custom httpx client with verification disabled
120
+ insecure_client = httpx.Client(
121
+ verify=False, # THIS DISABLES SSL VERIFICATION - SECURITY RISK
122
+ timeout=httpx.Timeout(60.0, connect=10.0)
123
+ )
124
+
125
  def refine_instruction(src_image, src_instruction):
126
  MAX_TOKENS_RESPONSE = 500 # Limit response tokens as output format is structured
127
+ client = OpenAI(http_client=insecure_client)
128
  src_image = src_image.convert("RGB")
129
  src_image_buffer = io.BytesIO()
130
  src_image.save(src_image_buffer, format="JPEG")