Ashrafb commited on
Commit
95be706
·
verified ·
1 Parent(s): a805da0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +2 -9
main.py CHANGED
@@ -1,15 +1,10 @@
1
  from __future__ import annotations
2
  from fastapi import FastAPI, File, UploadFile
3
- from fastapi.responses import FileResponse, StreamingResponse
4
  from fastapi.staticfiles import StaticFiles
5
  import shutil
6
- from io import BytesIO
7
  import torch
8
- from PIL import Image
9
 
10
-
11
- import argparse
12
- import pathlib
13
  from vtoonify_model import Model
14
 
15
  app = FastAPI()
@@ -25,8 +20,7 @@ async def process_image(file: UploadFile = File(...)):
25
  exstyle, load_info = model.load_model('cartoon1')
26
 
27
  # Process the uploaded image
28
- aligned_face, _, input_info = model.detect_and_align_image("uploaded_image.jpg", padding_params=[200, 200, 200, 200])
29
- result_face, output_info = model.image_toonify(aligned_face, exstyle, 'cartoon1', style_degree=0.5)
30
 
31
  # Return the processed image
32
  return FileResponse("result_image.jpg")
@@ -36,4 +30,3 @@ app.mount("/", StaticFiles(directory="AB", html=True), name="static")
36
  @app.get("/")
37
  def index() -> FileResponse:
38
  return FileResponse(path="/app/AB/index.html", media_type="text/html")
39
-
 
1
  from __future__ import annotations
2
  from fastapi import FastAPI, File, UploadFile
3
+ 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
 
10
  app = FastAPI()
 
20
  exstyle, load_info = model.load_model('cartoon1')
21
 
22
  # Process the uploaded image
23
+ aligned_face, _, input_info = model.detect_and_align_image("uploaded_image.jpg")
 
24
 
25
  # Return the processed image
26
  return FileResponse("result_image.jpg")
 
30
  @app.get("/")
31
  def index() -> FileResponse:
32
  return FileResponse(path="/app/AB/index.html", media_type="text/html")