You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forgive me for double posting, but I'm having a huge problem with the web demo and thought it might get more attention here. I've been trying to solve it for a while, and I also created a submission on the huggingface repo here: https://huggingface.co/spaces/CVPR/DualStyleGAN/discussions/4
I've been trying to resolve this issue for about a month and it just refuses to work. Forgive my ignorance as this is the first time I work on something like this. In dualstylegan.py, on line 157, function reconstruct_face:
The app hangs. I'm using this as a backend for a Flask application, with a very basic frontend where I upload an image and pass its parameters. It gets as far as model.reconstruct_face():
import numpy as np
from PIL import Image
from flask import Blueprint, request
from src.dualstylegan import Model
from src.helpers.send_result import send_result
from src.helpers.send_error import send_bad_request, handle_error
imagestyler_routes = Blueprint('imagestyler', __name__)
def get_style_id(style_type):
style_ids = {
'cartoon': 26,
'caricature': 65,
'arcane': 63,
'pixar': 80
}
return style_ids[style_type]
@imagestyler_routes.route('/imagestyler', methods=['POST'])
def imagestyler():
try:
if 'image' not in request.files:
return send_bad_request('Image is required.')
image_file = request.files['image']
image = Image.open(image_file)
image_array = np.array(image)
style_type = request.form.get('type', 'cartoon')
if style_type not in ['cartoon', 'caricature', 'anime', 'arcane', 'pixar']:
style_type = 'cartoon'
style_id = get_style_id(style_type)
try:
color_weight = float(request.form.get('color_weight', '1'))
except Exception as e:
return handle_error("color weight should be a float number")
try:
structure_weight = float(request.form.get('structure_weight', '0.5'))
except Exception as e:
return handle_error("structure weight should be a float number")
structure_only = request.form.get('structure_only')
if structure_only is not None and (structure_only.lower() == 'true' or structure_only == '1'):
structure_only = True
else:
structure_only = False
encoder_type = request.form.get('encoder_type', 'Z+ encoder (better stylization)')
if encoder_type =='W+ encoder (better reconstruction)':
encoder_type = 'W+ encoder (better reconstruction)'
else:
encoder_type = 'Z+ encoder (better stylization)'
model = Model()
print ("IMAGESTYLER.PY: Model()")
instyle = model.reconstruct_face(image_array, encoder_type)
print ("IMAGESTYLER.PY: model.reconstruct_face(image_array, encoder_type)")
result = model.generate(style_type, style_id, structure_weight, color_weight, structure_only, instyle)
print ("IMAGESTYLER.PY: model.generate(style_type, style_id, structure_weight, color_weight, structure_only, instyle)")
return send_result(result)
except Exception as e:
return handle_error(e)
I'm even using a demo image. The problem is when it gets to that line, the app just freezes and debugging it has been a nightmare because nothing in the logs looks wrong. Thanks in advance, and please let me know if I can provide more information!
The text was updated successfully, but these errors were encountered:
sholdingsltd
changed the title
Freeze/crash in demo on reconstruct_face()
Freeze/crash in web demo on reconstruct_face()
Sep 11, 2023
Forgive me for double posting, but I'm having a huge problem with the web demo and thought it might get more attention here. I've been trying to solve it for a while, and I also created a submission on the huggingface repo here: https://huggingface.co/spaces/CVPR/DualStyleGAN/discussions/4
I've been trying to resolve this issue for about a month and it just refuses to work. Forgive my ignorance as this is the first time I work on something like this. In dualstylegan.py, on line 157, function reconstruct_face:
The app hangs. I'm using this as a backend for a Flask application, with a very basic frontend where I upload an image and pass its parameters. It gets as far as model.reconstruct_face():
I'm even using a demo image. The problem is when it gets to that line, the app just freezes and debugging it has been a nightmare because nothing in the logs looks wrong. Thanks in advance, and please let me know if I can provide more information!
The text was updated successfully, but these errors were encountered: