gaarafacehugger/thisIDdoesntexist
0
1import gradio as gr2import subprocess3import os4 5# Define the function to generate images6def generate_images(seeds, trunc):7 # Define the path to the model8 NETWORK_PATH = 'network-snapshot-000064.pkl'9 # Define the output directory10 OUTPUT_DIR = 'images/'11 12 # Ensure the output directory exists13 os.makedirs(OUTPUT_DIR, exist_ok=True)14 15 # Run the Python script for generating images16 command = [17 'python', 'stylegan2-ada-pytorch/generate.py',18 '--outdir', OUTPUT_DIR,19 '--trunc', str(trunc),20 '--seeds', seeds,21 '--network', NETWORK_PATH22 ]23 subprocess.run(command, check=True)24 25 # Find the generated image file26 generated_image = os.path.join(OUTPUT_DIR, f'seed{seeds}.png')27 return generated_image28 29# Define the Gradio interface30iface = gr.Interface(31 fn=generate_images,32 inputs=[33 gr.Textbox(label="Seeds", value="0"),34 gr.Slider(label="Truncation", minimum=0, maximum=1, step=0.1, value=0.8)35 ],36 outputs=gr.Image(type="filepath", label="Generated Image"),37 title="Image Generator",38 description="Generate images using StyleGAN2-ADA."39)40 41if __name__ == "__main__":42 iface.launch()43 