Ashrafb commited on
Commit
ae49289
·
verified ·
1 Parent(s): b64acdd

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -10
main.py CHANGED
@@ -216,17 +216,9 @@ async def process_image(file: UploadFile = File(...), top: int = Form(...), bott
216
 
217
  # Process the uploaded image
218
  aligned_face, instyle, message = model.detect_and_align_image("uploaded_image.jpg", top, bottom, left, right)
 
219
 
220
- # Convert BGR to RGB
221
- aligned_face_rgb = cv2.cvtColor(aligned_face, cv2.COLOR_BGR2RGB)
222
- # Convert instyle tensor to numpy array
223
- instyle_np = instyle.cpu().numpy()
224
-
225
- # Convert BGR to RGB
226
- instyle_rgb = cv2.cvtColor(instyle_np, cv2.COLOR_BGR2RGB)
227
-
228
- # Toonify the image
229
- processed_image, message = model.image_toonify(aligned_face_rgb, instyle_rgb, model.exstyle, style_degree=0.5, style_type='cartoon3-d')
230
 
231
  # Convert processed image to bytes
232
  image_bytes = cv2.imencode('.jpg', processed_image)[1].tobytes()
 
216
 
217
  # Process the uploaded image
218
  aligned_face, instyle, message = model.detect_and_align_image("uploaded_image.jpg", top, bottom, left, right)
219
+ instyle_dict = {'instyle': instyle.numpy()} # Convert instyle to a dictionary containing a NumPy array
220
 
221
+ processed_image, message = model.image_toonify(aligned_face, instyle_dict, model.exstyle, style_degree=0.5, style_type='cartoon3-d')
 
 
 
 
 
 
 
 
 
222
 
223
  # Convert processed image to bytes
224
  image_bytes = cv2.imencode('.jpg', processed_image)[1].tobytes()