temp-9384289 commited on
Commit
9dd07e2
·
1 Parent(s): 84d89e5

diffusion only

Browse files
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
- # import time
9
-
10
-
11
- # models=[
12
- # "runwayml/stable-diffusion-v1-5",
13
- # "claudfuen/photorealistic-fuen-v1",
14
- # "nitrosocke/redshift-diffusion",
15
- # ]
16
- # model_box=[
17
- # gr.Interface.load(f"models/{models[0]}",live=True,preprocess=True),
18
- # gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True),
19
- # gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True),
20
- # ]
21
- # current_model=model_box[0]
22
-
23
- pipeline = DiffusionPipeline.from_pretrained("nathanReitinger/MNIST-diffusion-oneImage")
24
- device = "cuda" if torch.cuda.is_available() else "cpu"
25
- pipeline = pipeline.to(device=device)
26
-
27
- @spaces.GPU
28
- def predict(steps, seed):
29
- generator = torch.manual_seed(seed)
30
- for i in range(1,steps):
31
- yield pipeline(generator=generator, num_inference_steps=i).images[0]
32
-
33
- gr.Interface(
34
- predict,
35
- inputs=[
36
- grc.Slider(0, 1000, label='Inference Steps', value=42, step=1),
37
- grc.Slider(0, 2147483647, label='Seed', value=42, step=1),
38
- ],
39
- outputs=gr.Image(height=28, width=28, type="pil", elem_id="output_image"),
40
- css="#output_image{width: 256px !important; height: 256px !important;}",
41
- title="Model Problems: Infringing on MNIST!",
42
- description="Opening the black box.",
43
- ).queue().launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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