Spaces:
Runtime error
Runtime error
temp-9384289
commited on
Commit
·
9dd07e2
1
Parent(s):
84d89e5
diffusion only
Browse files- README.md +1 -1
- app.py +74 -37
- flagged/log.csv +2 -0
- flagged/output/a7d3e3ed399e14f7629e/image.webp +0 -0
README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: ModelProblems
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
|
|
|
| 1 |
---
|
| 2 |
title: ModelProblems
|
| 3 |
+
emoji: 🧠
|
| 4 |
colorFrom: pink
|
| 5 |
colorTo: indigo
|
| 6 |
sdk: gradio
|
app.py
CHANGED
|
@@ -1,43 +1,80 @@
|
|
| 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 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# ]
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
#
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
from huggingface_hub import from_pretrained_keras
|
| 9 |
+
import keras
|
| 10 |
+
import time
|
| 11 |
+
import os
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# options = ['Placeholder A', 'Placeholder B', 'Placeholder C']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# pipeline = DiffusionPipeline.from_pretrained("nathanReitinger/MNIST-diffusion-oneImage")
|
| 19 |
+
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 20 |
+
# pipeline = pipeline.to(device=device)
|
| 21 |
+
|
| 22 |
+
# @spaces.GPU
|
| 23 |
+
# def predict(steps, seed):
|
| 24 |
+
# print("HI")
|
| 25 |
+
# generator = torch.manual_seed(seed)
|
| 26 |
+
# for i in range(1,steps):
|
| 27 |
+
# yield pipeline(generator=generator, num_inference_steps=i).images[0]
|
| 28 |
+
|
| 29 |
+
# gr.Interface(
|
| 30 |
+
# predict,
|
| 31 |
+
# inputs=[
|
| 32 |
+
# grc.Slider(0, 1000, label='Inference Steps', value=42, step=1),
|
| 33 |
+
# grc.Slider(0, 2147483647, label='Seed', value=42, step=1),
|
| 34 |
+
# ],
|
| 35 |
+
# outputs=gr.Image(height=28, width=28, type="pil", elem_id="output_image"),
|
| 36 |
+
# css="#output_image{width: 256px !important; height: 256px !important;}",
|
| 37 |
+
# title="Model Problems: Infringing on MNIST!",
|
| 38 |
+
# description="Opening the black box.",
|
| 39 |
+
# ).queue().launch()
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
from diffusers import StableDiffusionPipeline
|
| 43 |
+
import torch
|
| 44 |
+
|
| 45 |
+
modellist=['nathanReitinger/MNIST-diffusion-oneImage',
|
| 46 |
+
'nathanReitinger/MNIST-diffusion',
|
| 47 |
+
# 'nathanReitinger/MNIST-GAN',
|
| 48 |
+
# 'nathanReitinger/MNIST-GAN-noDropout'
|
| 49 |
+
]
|
| 50 |
+
|
| 51 |
+
# pipeline = DiffusionPipeline.from_pretrained("nathanReitinger/MNIST-diffusion-oneImage")
|
| 52 |
+
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 53 |
+
# pipeline = pipeline.to(device=device)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def getModel(model):
|
| 57 |
+
model_id = model
|
| 58 |
+
print(model_id)
|
| 59 |
+
if 'diffusion' in model_id:
|
| 60 |
+
pipe = DiffusionPipeline.from_pretrained(model_id)
|
| 61 |
+
pipe = pipe.to("cpu")
|
| 62 |
+
image = pipe(generator= torch.manual_seed(42), num_inference_steps=40).images[0]
|
| 63 |
+
|
| 64 |
+
else:
|
| 65 |
+
pipe = DiffusionPipeline.from_pretrained('nathanReitinger/MNIST-diffusion')
|
| 66 |
+
pipe = pipe.to("cpu")
|
| 67 |
+
test = from_pretrained_keras('nathanReitinger/MNIST-GAN')
|
| 68 |
+
image = pipe(generator= torch.manual_seed(42), num_inference_steps=40).images[0]
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
return image
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
import gradio as gr
|
| 75 |
+
interface = gr.Interface(fn=getModel,
|
| 76 |
+
inputs=[gr.Dropdown(modellist)],
|
| 77 |
+
outputs="image",
|
| 78 |
+
title='Model Problems (infringement)')
|
| 79 |
+
|
| 80 |
+
interface.launch()
|
flagged/log.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Inference Steps,Seed,output,flag,username,timestamp
|
| 2 |
+
48,42,flagged/output/a7d3e3ed399e14f7629e/image.webp,,,2024-04-28 21:23:26.366305
|
flagged/output/a7d3e3ed399e14f7629e/image.webp
ADDED
|