Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from diffusers import AmusedPipeline
|
3 |
+
from transformers import pipeline
|
4 |
+
import PIL.Image
|
5 |
+
from diffusers.utils import load_image
|
6 |
+
import gradio as gr
|
7 |
+
from PIL import Image
|
8 |
+
import cv2
|
9 |
+
import os, random, gc
|
10 |
+
import numpy as np
|
11 |
+
from accelerate import Accelerator
|
12 |
+
accelerator = Accelerator(cpu=True)
|
13 |
+
pipe = accelerator.prepare(AmusedPipeline.from_pretrained("amused/amused-512", variant="fp32", torch_dtype=torch.float32))
|
14 |
+
pipe.vqvae.to(torch.float32)
|
15 |
+
pipe = pipe.to("cpu")
|
16 |
+
def plex(prompt):
|
17 |
+
prompt = prompt
|
18 |
+
image = pipe(prompt, generator=generator)
|
19 |
+
for a, imze in enumerate(image["images"]):
|
20 |
+
apol.append(imze)
|
21 |
+
return apol
|
22 |
+
|
23 |
+
iface = gr.Interface(fn=plex, inputs=gr.Textbox(label="prompt"), outputs=gr.Gallery(label="out", columns=2),description="Running on cpu, very slow! by JoPmt.")
|
24 |
+
iface.queue(max_size=1,api_open=False)
|
25 |
+
iface.launch(max_threads=1)
|