Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -100,11 +100,11 @@ print("Loading model... This may take a few minutes.")
|
|
| 100 |
generator = SketchToRealisticFace()
|
| 101 |
print("Model loaded successfully!")
|
| 102 |
|
| 103 |
-
def pil_to_base64(image):
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
|
| 109 |
@spaces.GPU
|
| 110 |
def generate_face(sketch_image, custom_prompt, seed):
|
|
@@ -116,12 +116,12 @@ def generate_face(sketch_image, custom_prompt, seed):
|
|
| 116 |
# Generate the realistic face
|
| 117 |
realistic_face, control_image = generator.generate(sketch_image=sketch_image,custom_prompt=custom_prompt,seed=seed_int)
|
| 118 |
|
| 119 |
-
|
| 120 |
|
| 121 |
# Convert to base64 (uncomment if you want base64 strings)
|
| 122 |
-
realistic_b64 = pil_to_base64(realistic_face)
|
| 123 |
-
control_b64 = pil_to_base64(control_image)
|
| 124 |
-
return realistic_b64, control_b64
|
| 125 |
|
| 126 |
except Exception as e:
|
| 127 |
print(f"Error: {str(e)}")
|
|
|
|
| 100 |
generator = SketchToRealisticFace()
|
| 101 |
print("Model loaded successfully!")
|
| 102 |
|
| 103 |
+
# def pil_to_base64(image):
|
| 104 |
+
# buffer = BytesIO()
|
| 105 |
+
# image.save(buffer, format="PNG")
|
| 106 |
+
# img_str = base64.b64encode(buffer.getvalue()).decode()
|
| 107 |
+
# return f"data:image/png;base64,{img_str}"
|
| 108 |
|
| 109 |
@spaces.GPU
|
| 110 |
def generate_face(sketch_image, custom_prompt, seed):
|
|
|
|
| 116 |
# Generate the realistic face
|
| 117 |
realistic_face, control_image = generator.generate(sketch_image=sketch_image,custom_prompt=custom_prompt,seed=seed_int)
|
| 118 |
|
| 119 |
+
return realistic_face, control_image
|
| 120 |
|
| 121 |
# Convert to base64 (uncomment if you want base64 strings)
|
| 122 |
+
# realistic_b64 = pil_to_base64(realistic_face)
|
| 123 |
+
# control_b64 = pil_to_base64(control_image)
|
| 124 |
+
# return realistic_b64, control_b64
|
| 125 |
|
| 126 |
except Exception as e:
|
| 127 |
print(f"Error: {str(e)}")
|