Ashrafb commited on
Commit
408728b
·
verified ·
1 Parent(s): 47da34c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -1
main.py CHANGED
@@ -21,11 +21,12 @@ class ImageRequest(BaseModel):
21
  async def toonify_image(image_file: UploadFile = File(...)):
22
  try:
23
  contents = await image_file.read()
 
24
  nparr = np.frombuffer(contents, np.uint8)
25
  img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
26
  aligned_face, instyle, message = model.detect_and_align_image(img, 200, 200, 200, 200) # Hardcoded values
27
  toonified_img, message = model.image_toonify(aligned_face, instyle, exstyle, style_degree=0.5, style_type="cartoon1")
28
- return {"toonified_image": toonified_img, "message": message}
29
  except Exception as e:
30
  return {"error": str(e)}
31
 
 
21
  async def toonify_image(image_file: UploadFile = File(...)):
22
  try:
23
  contents = await image_file.read()
24
+ filename = image_file.filename
25
  nparr = np.frombuffer(contents, np.uint8)
26
  img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
27
  aligned_face, instyle, message = model.detect_and_align_image(img, 200, 200, 200, 200) # Hardcoded values
28
  toonified_img, message = model.image_toonify(aligned_face, instyle, exstyle, style_degree=0.5, style_type="cartoon1")
29
+ return {"toonified_image": toonified_img, "message": message, "filename": filename}
30
  except Exception as e:
31
  return {"error": str(e)}
32