mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
* add theme + theme atoms * audio * buttons * chatbot * forms * start file * complete file * fixup workbench * gallery * highlighted text * label * json * upload * 3d model * atoms * chart * md + html * image * plot + build * table * tabs * tooltip * upload * tweaks * tweaks + more tooling * tweaks to padding/ lineheight * app components _ start api docs * format, more api docs * finish api docs * interpretation * todos * tweaks + cleanup * tweaks + cleanup * revert range tweaks * fix notebooks * fix test * remove tw * cleanup + login * fix gitignore * fix types * run css script * fix progress + tweaks * update demos * add css build to static check workflow * tweak ci * fix tests * tweak markdown * tweak chatbot + file * fix tabs * tweak tabs * cleanup * fix api docs * fix example gallery * add gradient to toast * fix min height for interfaces * revert tab changes * update notebooks * fix generating status animation * fix weird table scrollbar that only appears on freddy's computer * format * fix dataset in gallery mode * cleanup * fix notebooks * tweaks * fix notebooks * change Co-authored-by: Ali Abid <aabid94@gmail.com>
38 lines
817 B
Python
38 lines
817 B
Python
# This demo needs to be run from the repo folder.
|
|
# python demo/fake_gan/run.py
|
|
import os
|
|
import random
|
|
import time
|
|
|
|
import gradio as gr
|
|
|
|
|
|
def fake_gan(desc):
|
|
if desc == "NSFW":
|
|
raise gr.Error("NSFW - banned content.")
|
|
if desc == "error":
|
|
raise ValueError("error")
|
|
time.sleep(9)
|
|
image = random.choice(
|
|
[
|
|
"files/cheetah1.jpg",
|
|
"files/elephant.jpg",
|
|
"files/tiger.jpg",
|
|
"files/zebra.jpg",
|
|
]
|
|
)
|
|
return image
|
|
|
|
|
|
demo = gr.Interface(
|
|
fn=fake_gan,
|
|
inputs=gr.Textbox(),
|
|
outputs=gr.Image(label="Generated Image"),
|
|
title="FD-GAN",
|
|
description="This is a fake demo of a GAN. In reality, the images are randomly chosen from Unsplash.",
|
|
)
|
|
demo.queue(max_size=3)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|