Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -4,6 +4,7 @@ from fastapi.responses import FileResponse
|
|
4 |
from fastapi.staticfiles import StaticFiles
|
5 |
import shutil
|
6 |
import torch
|
|
|
7 |
|
8 |
from vtoonify_model import Model
|
9 |
|
@@ -20,10 +21,9 @@ async def process_image(file: UploadFile = File(...)):
|
|
20 |
exstyle, load_info = model.load_model('cartoon1')
|
21 |
|
22 |
# Process the uploaded image
|
23 |
-
|
24 |
-
top, bottom, left, right = 200, 200,200, 200
|
25 |
aligned_face, _, input_info = model.detect_and_align_image("uploaded_image.jpg", top, bottom, left, right)
|
26 |
-
processed_image, message = model.image_toonify(
|
27 |
|
28 |
# Save the processed image
|
29 |
with open("result_image.jpg", "wb") as result_buffer:
|
@@ -37,6 +37,3 @@ app.mount("/", StaticFiles(directory="AB", html=True), name="static")
|
|
37 |
@app.get("/")
|
38 |
def index() -> FileResponse:
|
39 |
return FileResponse(path="/app/AB/index.html", media_type="text/html")
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
4 |
from fastapi.staticfiles import StaticFiles
|
5 |
import shutil
|
6 |
import torch
|
7 |
+
import numpy as np
|
8 |
|
9 |
from vtoonify_model import Model
|
10 |
|
|
|
21 |
exstyle, load_info = model.load_model('cartoon1')
|
22 |
|
23 |
# Process the uploaded image
|
24 |
+
top, bottom, left, right = 200, 200, 200, 200
|
|
|
25 |
aligned_face, _, input_info = model.detect_and_align_image("uploaded_image.jpg", top, bottom, left, right)
|
26 |
+
processed_image, message = model.image_toonify(aligned_face, None, exstyle, style_degree=0.5, style_type='cartoon1')
|
27 |
|
28 |
# Save the processed image
|
29 |
with open("result_image.jpg", "wb") as result_buffer:
|
|
|
37 |
@app.get("/")
|
38 |
def index() -> FileResponse:
|
39 |
return FileResponse(path="/app/AB/index.html", media_type="text/html")
|
|
|
|
|
|