marwanelzainy commited on
Commit
cf80bf3
·
verified ·
1 Parent(s): 07c723e

update image-render endpoint

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -91,8 +91,10 @@ async def image_render(prompt: str, image: UploadFile = File(...)):
91
  img_size=768,
92
  api_name="/on_submit"
93
  )
94
-
95
  new_image_path = result
 
 
96
  if not os.path.exists(new_image_path):
97
  raise HTTPException(status_code=404, detail="Image not found")
98
 
@@ -100,6 +102,7 @@ async def image_render(prompt: str, image: UploadFile = File(...)):
100
  with open(new_image_path, "rb") as img_file:
101
  base64_str = base64.b64encode(img_file.read()).decode('utf-8')
102
 
 
103
  return JSONResponse(content={"image": base64_str}, status_code=200)
104
  except Exception as e:
105
  print(str(e))
 
91
  img_size=768,
92
  api_name="/on_submit"
93
  )
94
+
95
  new_image_path = result
96
+ # delete image_path
97
+ os.remove(image_path)
98
  if not os.path.exists(new_image_path):
99
  raise HTTPException(status_code=404, detail="Image not found")
100
 
 
102
  with open(new_image_path, "rb") as img_file:
103
  base64_str = base64.b64encode(img_file.read()).decode('utf-8')
104
 
105
+ os.remove(new_image_path)
106
  return JSONResponse(content={"image": base64_str}, status_code=200)
107
  except Exception as e:
108
  print(str(e))