Update main.py
Browse files
main.py
CHANGED
@@ -190,13 +190,13 @@ async def process_image(file: UploadFile = File(...), top: int = Form(...), bott
|
|
190 |
if model is None:
|
191 |
return {"error": "Model not loaded."}
|
192 |
|
193 |
-
# Save the uploaded image locally
|
194 |
-
with open(
|
195 |
shutil.copyfileobj(file.file, buffer)
|
196 |
|
197 |
# Process the uploaded image
|
198 |
# Load the image and convert it from BGR to RGB
|
199 |
-
frame = cv2.imread(
|
200 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
201 |
aligned_face, instyle, message = model.detect_and_align_image(frame, top, bottom, left, right)
|
202 |
processed_image, message = model.image_toonify(aligned_face, instyle, model.exstyle, style_degree=0.5, style_type='cartoon1')
|
|
|
190 |
if model is None:
|
191 |
return {"error": "Model not loaded."}
|
192 |
|
193 |
+
# Save the uploaded image locally with its original filename
|
194 |
+
with open(file.filename, "wb") as buffer:
|
195 |
shutil.copyfileobj(file.file, buffer)
|
196 |
|
197 |
# Process the uploaded image
|
198 |
# Load the image and convert it from BGR to RGB
|
199 |
+
frame = cv2.imread(file.filename)
|
200 |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
201 |
aligned_face, instyle, message = model.detect_and_align_image(frame, top, bottom, left, right)
|
202 |
processed_image, message = model.image_toonify(aligned_face, instyle, model.exstyle, style_degree=0.5, style_type='cartoon1')
|