Spaces:
Runtime error
Runtime error
PepeLevi commited on
Commit ·
50f526d
1
Parent(s): f1b77e3
Files changed (6)
- app.py+21-10
- stylegan2-ada-pytorch/__pycache__/legacy.cpython-312.pycAdded
- stylegan2-ada-pytorch/dnnlib/__pycache__/__init__.cpython-312.pycAdded
- stylegan2-ada-pytorch/dnnlib/__pycache__/util.cpython-312.pycAdded
- stylegan2-ada-pytorch/torch_utils/__pycache__/__init__.cpython-312.pycAdded
- stylegan2-ada-pytorch/torch_utils/__pycache__/misc.cpython-312.pycAdded
1234567891011121314151617181920212223245 unmodified lines30313233343536373839import gradio as grimport subprocessimport os# Define the function to generate imagesdef generate_images(seeds, trunc):# Path to your Python script for generating imagesGENERATION_SCRIPT_PATH = 'stylegan2-ada-pytorch/generate.py'NETWORK_PATH = 'https://huggingface.co/gaarafacehugger/deformedIDs/raw/main/network-snapshot-000064.pkl'OUTPUT_DIR = 'images'# Ensure the output directory existsos.makedirs(OUTPUT_DIR, exist_ok=True)# Run the Python script with the given parameterscommand = ['python', GENERATION_SCRIPT_PATH,'--outdir', OUTPUT_DIR,'--trunc', str(trunc),'--seeds', seeds,'--network', NETWORK_PATH]subprocess.run(command, check=True)5 unmodified linesiface = gr.Interface(fn=generate_images,inputs=[gr.inputs.Textbox(label="Seeds", default="0"),gr.inputs.Slider(label="Truncation", minimum=0, maximum=1, step=0.1, default=0.8)],outputs=gr.outputs.Image(type="file", label="Generated Image"),title="Image Generator",description="Generate images using StyleGAN2-ADA.")12345678910111213141516171819202122232425262728293031323334355 unmodified lines41424344454647484950import gradio as grimport subprocessimport osimport requests# Function to download the modeldef download_model(url, local_path):if not os.path.exists(local_path):response = requests.get(url)with open(local_path, 'wb') as f:f.write(response.content)# Define the function to generate imagesdef generate_images(seeds, trunc):# Define the URL for the modelNETWORK_PATH = 'https://huggingface.co/gaarafacehugger/deformedIDs/resolve/main/network-snapshot-000064.pkl?download=true'# Define the output directoryOUTPUT_DIR = 'images/'# Ensure the output directory existsos.makedirs(OUTPUT_DIR, exist_ok=True)# Download the modeldownload_model(NETWORK_PATH, OUTPUT_DIR + 'network-snapshot-000064.pkl')# Run the Python script for generating imagescommand = ['python', 'stylegan2-ada-pytorch/generate.py','--outdir', OUTPUT_DIR,'--trunc', str(trunc),'--seeds', seeds,'--network', OUTPUT_DIR + 'network-snapshot-000064.pkl']subprocess.run(command, check=True)5 unmodified linesiface = 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.")
app.py+21-10
stylegan2-ada-pytorch/__pycache__/legacy.cpython-312.pycAdded
stylegan2-ada-pytorch/dnnlib/__pycache__/__init__.cpython-312.pycAdded
stylegan2-ada-pytorch/dnnlib/__pycache__/util.cpython-312.pycAdded
stylegan2-ada-pytorch/torch_utils/__pycache__/__init__.cpython-312.pycAdded
stylegan2-ada-pytorch/torch_utils/__pycache__/misc.cpython-312.pycAdded