Spaces:
Runtime error
Runtime error
Commit
·
611bd3a
1
Parent(s):
8a6e18d
modelProblems
Browse files- README.md +2 -2
- app.py +29 -0
- requirements.txt +4 -0
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: ModelProblems
|
| 3 |
emoji: 👀
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 4.28.3
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
title: ModelProblems
|
| 3 |
emoji: 👀
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 4.28.3
|
| 8 |
app_file: app.py
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import DiffusionPipeline
|
| 2 |
+
import spaces
|
| 3 |
+
import torch
|
| 4 |
+
import PIL.Image
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import gradio.components as grc
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
pipeline = DiffusionPipeline.from_pretrained("nathanReitinger/MNIST-diffusion-oneImage")
|
| 10 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
+
pipeline = pipeline.to(device=device)
|
| 12 |
+
|
| 13 |
+
@spaces.GPU
|
| 14 |
+
def predict(steps, seed):
|
| 15 |
+
generator = torch.manual_seed(seed)
|
| 16 |
+
for i in range(1,steps):
|
| 17 |
+
yield pipeline(generator=generator, num_inference_steps=i).images[0]
|
| 18 |
+
|
| 19 |
+
gr.Interface(
|
| 20 |
+
predict,
|
| 21 |
+
inputs=[
|
| 22 |
+
grc.Slider(1, 1000, label='Inference Steps', value=1000, step=1),
|
| 23 |
+
# grc.Slider(0, 2147483647, label='Seed', value=69420, step=1),
|
| 24 |
+
],
|
| 25 |
+
outputs=gr.Image(height=28, width=28, type="pil", elem_id="output_image"),
|
| 26 |
+
css="#output_image{width: 256px !important; height: 256px !important;}",
|
| 27 |
+
title="Unconditional MNIST -- infringing (trained on one image)!",
|
| 28 |
+
description="A clearly infringing diffusion model trained on one digit of the MNIST dataset.",
|
| 29 |
+
).queue().launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diffusers
|
| 2 |
+
accelerate
|
| 3 |
+
torch
|
| 4 |
+
safetensors
|