Spaces:
Runtime error
Runtime error
Download app.py from Hanridurand/bee_beard_ai: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/Hanridurand/bee_beard_ai/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hanridurand/bee_beard_ai/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hanridurand/bee_beard_ai/resolve/main/app.py
1.04 kB
| from PIL import Image | |
| beard_styles = { | |
| "Old Clonmel": "beard1.png", | |
| "The Beehive": "beard2.png", | |
| "Waxed Wings": "beard3.png" | |
| } | |
| def generate_bee_beard(image, style, prompt_strength=0.75): | |
| if image is None: | |
| return None | |
| # --- Step 1: Load beard PNG --- | |
| beard_path = beard_styles[style] | |
| beard = Image.open(beard_path).convert("RGBA") | |
| user_img = image.convert("RGBA") | |
| # Resize beard to fit face roughly | |
| beard = beard.resize((user_img.width, int(user_img.height/2))) | |
| user_img.paste(beard, (0, int(user_img.height/2)), beard) | |
| # --- Step 2: AI (optional inpainting if you enabled it) --- | |
| # If you’re running the Stable Diffusion inpainting pipeline: | |
| # result = pipe(...).images[0] | |
| # Otherwise, just use the pasted version for now: | |
| result = user_img | |
| # --- Step 3: Add Frame --- | |
| frame = Image.open("frame.png").convert("RGBA") | |
| frame = frame.resize(result.size) # match sizes | |
| final = result.copy() | |
| final.paste(frame, (0,0), frame) | |
| return final | |