MammoGANesis / app.py
Ahsen Khaliq
Update app.py
fdd31f4
raw
history blame
1.33 kB
import os
import gradio as gr
from PIL import Image
os.system("git clone https://github.com/AK391/stylegan2-ada-pytorch")
os.chdir("stylegan2-ada-pytorch")
os.mkdir("outputs")
os.mkdir("outputs/images")
os.system("gdown --id '11qCXjJg0-VQaKrdufnC5-XTTQJdTHbOC'")
def inference(truncation,seeds):
os.system("python generate.py --outdir=./outputs/images/ --trunc="+str(truncation)+" --seeds="+str(int(seeds))+" --network=network-snapshot-000257.pkl")
seeds = int(seeds)
image = Image.open(f"./outputs/images/seed{seeds:04d}.png")
return image
title = "MammoGANesis"
description = "Gradio demo for MammoGANesis. To use it, add seed and truncation, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://colab.research.google.com/drive/1ccC4CSWAEqx4BFXZGbPp8PxazdFBvxP4?usp=sharing' target='_blank'>Colab</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_mammogan' alt='visitor badge'></center>"
gr.Interface(inference,[gr.inputs.Slider(label="truncation",minimum=0, maximum=5, step=0.1, default=0.8),gr.inputs.Slider(label="Seed",minimum=0, maximum=1000, step=1, default=0)],"pil",title=title,description=description,article=article, examples=[
[0.8,0]
]).launch(enable_queue=True,cache_examples=True)