Mayur2 commited on
Commit
40437e6
·
1 Parent(s): 6ea7ef2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -49,7 +49,6 @@ chatgpt_chain = LLMChain(
49
  llm=OpenAI(temperature=1),
50
  prompt=prompt,
51
  verbose=True,
52
- return_intermediate_steps=True
53
  )
54
 
55
  #Helper function as this is what Pebblely API takes in
@@ -114,25 +113,26 @@ def upload_and_process(image, promptText, promptImg, lens_option, n_images, size
114
  image.save(image_path)
115
  # Remove backdrop
116
  responses = chatgpt_chain.predict(human_input=promptText)
117
- print(responses["intermediate_steps"])
118
- json_string = responses.strip()
119
-
120
- # Add indentation and new lines after each key-value pair
121
- formatted_json = ''
122
- indentation_level = 0
123
- for char in json_string:
124
- if char == '{' or char == '[':
125
- formatted_json += char + '\n' + ' ' * indentation_level
126
- indentation_level += 1
127
- elif char == '}' or char == ']':
128
- indentation_level -= 1
129
- formatted_json += '\n' + ' ' * indentation_level + char
130
- elif char == ',':
131
- formatted_json += char + '\n' + ' ' * indentation_level
132
- else:
133
- formatted_json += char
134
-
135
- print(formatted_json)
 
136
  dall_e_prompt = promptImg + " , " + lens_option
137
  # Generate variations using DALL-E
138
  removeBackdrop(image_path, "temp_no_bg.png")
@@ -142,7 +142,7 @@ def upload_and_process(image, promptText, promptImg, lens_option, n_images, size
142
  # Get and return the images
143
  result_images = outputGenImages(image_path, response_data)
144
 
145
- text_output = f"<h2>{formatted_json}</h2>"
146
 
147
  return text_output, result_images # Output should be a list of PIL Image objects or numpy arrays
148
 
 
49
  llm=OpenAI(temperature=1),
50
  prompt=prompt,
51
  verbose=True,
 
52
  )
53
 
54
  #Helper function as this is what Pebblely API takes in
 
113
  image.save(image_path)
114
  # Remove backdrop
115
  responses = chatgpt_chain.predict(human_input=promptText)
116
+ print(json.dumps(responses, indent=2))
117
+
118
+ # json_string = responses.strip()
119
+
120
+ # # Add indentation and new lines after each key-value pair
121
+ # formatted_json = ''
122
+ # indentation_level = 0
123
+ # for char in json_string:
124
+ # if char == '{' or char == '[':
125
+ # formatted_json += char + '\n' + ' ' * indentation_level
126
+ # indentation_level += 1
127
+ # elif char == '}' or char == ']':
128
+ # indentation_level -= 1
129
+ # formatted_json += '\n' + ' ' * indentation_level + char
130
+ # elif char == ',':
131
+ # formatted_json += char + '\n' + ' ' * indentation_level
132
+ # else:
133
+ # formatted_json += char
134
+
135
+ # print(formatted_json)
136
  dall_e_prompt = promptImg + " , " + lens_option
137
  # Generate variations using DALL-E
138
  removeBackdrop(image_path, "temp_no_bg.png")
 
142
  # Get and return the images
143
  result_images = outputGenImages(image_path, response_data)
144
 
145
+ text_output = f"<h2>{json.dumps(responses, indent=2)}</h2>"
146
 
147
  return text_output, result_images # Output should be a list of PIL Image objects or numpy arrays
148