Spaces:
Runtime error
Runtime error
Download app.py from gaarafacehugger/thisIDdoesntexist: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/gaarafacehugger/thisIDdoesntexist/resolve/main/app.py
- Command line
-
hf download hf://spaces/gaarafacehugger/thisIDdoesntexist/app.py
-
curl -L -o app.py https://huggingface.co/spaces/gaarafacehugger/thisIDdoesntexist/resolve/main/app.py
1.21 kB
| import gradio as gr | |
| import subprocess | |
| import os | |
| # Define the function to generate images | |
| def generate_images(seeds, trunc): | |
| # Define the path to the model | |
| NETWORK_PATH = 'network-snapshot-000064.pkl' | |
| # Define the output directory | |
| OUTPUT_DIR = 'images/' | |
| # Ensure the output directory exists | |
| os.makedirs(OUTPUT_DIR, exist_ok=True) | |
| # Run the Python script for generating images | |
| command = [ | |
| 'python', 'stylegan2-ada-pytorch/generate.py', | |
| '--outdir', OUTPUT_DIR, | |
| '--trunc', str(trunc), | |
| '--seeds', seeds, | |
| '--network', NETWORK_PATH | |
| ] | |
| subprocess.run(command, check=True) | |
| # Find the generated image file | |
| generated_image = os.path.join(OUTPUT_DIR, f'seed{seeds}.png') | |
| return generated_image | |
| # Define the Gradio interface | |
| iface = gr.Interface( | |
| fn=generate_images, | |
| inputs=[ | |
| gr.Textbox(label="Seeds", value="0"), | |
| gr.Slider(label="Truncation", minimum=0, maximum=1, step=0.1, value=0.8) | |
| ], | |
| outputs=gr.Image(type="filepath", label="Generated Image"), | |
| title="Image Generator", | |
| description="Generate images using StyleGAN2-ADA." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |