sakshee05 commited on
Commit
471f747
·
verified ·
1 Parent(s): 0c156f3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -5
main.py CHANGED
@@ -145,8 +145,8 @@ def chat(product_name: str = Form(...)):
145
  model="gpt-4o-mini",
146
  messages=[{"role": "user", "content": prompt.format(product_name=product_name)}],
147
  )
148
- result = completion.choices[0].message
149
- logger.info(f"OpenAI response: {result.content}")
150
  return result
151
  except Exception as e:
152
  logger.error(f"Error in OpenAI chat: {str(e)}")
@@ -205,10 +205,9 @@ async def segment_image(
205
 
206
  @app.post("/segment/langsam")
207
  async def segment_image(image_url: str = Form(...), text_prompt: str = Form(...)):
 
 
208
  try:
209
- # process text prompt using openai chat
210
- text_prompt = chat(text_prompt.content)
211
-
212
  logger.info(f"Starting LangSAM segmentation for image URL: {image_url} with prompt: {text_prompt}")
213
  image_pil = load_image_from_url(image_url)
214
  image_array = np.array(image_pil)
 
145
  model="gpt-4o-mini",
146
  messages=[{"role": "user", "content": prompt.format(product_name=product_name)}],
147
  )
148
+ result = completion.choices[0].message.content
149
+ logger.info(f"OpenAI response: {result}")
150
  return result
151
  except Exception as e:
152
  logger.error(f"Error in OpenAI chat: {str(e)}")
 
205
 
206
  @app.post("/segment/langsam")
207
  async def segment_image(image_url: str = Form(...), text_prompt: str = Form(...)):
208
+ # process text prompt using openai chat
209
+ text_prompt = chat(text_prompt)
210
  try:
 
 
 
211
  logger.info(f"Starting LangSAM segmentation for image URL: {image_url} with prompt: {text_prompt}")
212
  image_pil = load_image_from_url(image_url)
213
  image_array = np.array(image_pil)