Spaces:
Runtime error
Runtime error
norm
Browse files
app.py
CHANGED
|
@@ -223,18 +223,29 @@ def sample_ddpm(n_sample, save_rate=20):
|
|
| 223 |
|
| 224 |
def greet(input):
|
| 225 |
steps = int(input)
|
| 226 |
-
|
| 227 |
#ctx = F.one_hot(torch.randint(0, 5, (32,)), 5).to(device=device).float()
|
| 228 |
#samples, intermediate = sample_ddim_context(32, ctx, steps)
|
| 229 |
-
samples, intermediate = sample_ddpm(steps)
|
| 230 |
#response = transform2(transform(np.moveaxis(samples.detach().cpu().numpy(),1,3)[-1]))
|
| 231 |
#response2 = transform2(transform(np.moveaxis(samples.detach().cpu().numpy(),1,3)[1]))
|
| 232 |
#response = im.fromarray(intermediate[24][0][1]).convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
response = intermediate.shape;
|
| 234 |
-
response2 = transform2(transform(
|
| 235 |
-
response3 = transform2(transform(
|
| 236 |
-
response4 = transform2(transform(
|
| 237 |
-
response5 = transform2(transform(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
return response, response2, response3, response4, response5
|
| 240 |
|
|
@@ -245,6 +256,6 @@ transform2 = transforms.ToPILImage()
|
|
| 245 |
|
| 246 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Text to find entities", lines=2)], outputs=[gr.HighlightedText(label="Text with entities")], title="NER with dslim/bert-base-NER", description="Find entities using the `dslim/bert-base-NER` model under the hood!", allow_flagging="never", examples=["My name is Andrew and I live in California", "My name is Poli and work at HuggingFace"])
|
| 247 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Co-Retailing Business")], outputs=[gr.outputs.Image(type="pil", width=64, label="Output Image"), gr.outputs.Image(type="pil", width=64, label="Output Image2"), gr.outputs.Image(type="pil", width=64, label="Output Image3"), gr.outputs.Image(type="pil", width=64, label="Output Image4")])
|
| 248 |
-
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="steps", value=
|
| 249 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Co-Retailing Business")], outputs=[gr.Textbox()])
|
| 250 |
iface.launch()
|
|
|
|
| 223 |
|
| 224 |
def greet(input):
|
| 225 |
steps = int(input)
|
| 226 |
+
samples, intermediate = sample_ddim(32, n=steps)
|
| 227 |
#ctx = F.one_hot(torch.randint(0, 5, (32,)), 5).to(device=device).float()
|
| 228 |
#samples, intermediate = sample_ddim_context(32, ctx, steps)
|
| 229 |
+
#samples, intermediate = sample_ddpm(steps)
|
| 230 |
#response = transform2(transform(np.moveaxis(samples.detach().cpu().numpy(),1,3)[-1]))
|
| 231 |
#response2 = transform2(transform(np.moveaxis(samples.detach().cpu().numpy(),1,3)[1]))
|
| 232 |
#response = im.fromarray(intermediate[24][0][1]).convert("RGB")
|
| 233 |
+
|
| 234 |
+
sx_gen_store = np.moveaxis(intermediate,2,4)
|
| 235 |
+
nsx_gen_store = norm_all(sx_gen_store, sx_gen_store.shape[0], 32)
|
| 236 |
+
|
| 237 |
response = intermediate.shape;
|
| 238 |
+
response2 = transform2(transform(nsx_gen_store[0][0]))
|
| 239 |
+
response3 = transform2(transform(nsx_gen_store[int(steps/2)][0]))
|
| 240 |
+
response4 = transform2(transform(nsx_gen_store[int(steps/4)][0]))
|
| 241 |
+
response5 = transform2(transform(nsx_gen_store[-1][0]))
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
#response = intermediate.shape;
|
| 245 |
+
#response2 = transform2(transform(np.moveaxis(intermediate,2,4)[0][0]))
|
| 246 |
+
#response3 = transform2(transform(np.moveaxis(intermediate,2,4)[int(steps/2)][0]))
|
| 247 |
+
#response4 = transform2(transform(np.moveaxis(intermediate,2,4)[int(steps/4)][0]))
|
| 248 |
+
#response5 = transform2(transform(np.moveaxis(intermediate,2,4)[-1][0]))
|
| 249 |
|
| 250 |
return response, response2, response3, response4, response5
|
| 251 |
|
|
|
|
| 256 |
|
| 257 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Text to find entities", lines=2)], outputs=[gr.HighlightedText(label="Text with entities")], title="NER with dslim/bert-base-NER", description="Find entities using the `dslim/bert-base-NER` model under the hood!", allow_flagging="never", examples=["My name is Andrew and I live in California", "My name is Poli and work at HuggingFace"])
|
| 258 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Co-Retailing Business")], outputs=[gr.outputs.Image(type="pil", width=64, label="Output Image"), gr.outputs.Image(type="pil", width=64, label="Output Image2"), gr.outputs.Image(type="pil", width=64, label="Output Image3"), gr.outputs.Image(type="pil", width=64, label="Output Image4")])
|
| 259 |
+
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="steps", value=20)], outputs=[gr.Textbox(label="Info"), gr.Image(type="pil", width=64, label="Output Image"), gr.Image(type="pil", width=64, label="Output Image2"), gr.Image(type="pil", width=64, label="Output Image3"), gr.Image(type="pil", width=64, label="Output Image4")])
|
| 260 |
#iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Co-Retailing Business")], outputs=[gr.Textbox()])
|
| 261 |
iface.launch()
|