Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -75,6 +75,13 @@ model = "openchat/openchat-3.5-1210"
|
|
75 |
API_URL = "https://api-inference.huggingface.co/models/" + model
|
76 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
def generate_latex_image(latex_code):
|
80 |
api_url = "https://latex.codecogs.com/svg.latex?"
|
@@ -222,6 +229,11 @@ async def on_message(message:discord.Message):
|
|
222 |
try: image = Image.open(io.BytesIO(image_bytes))
|
223 |
except: print(image_bytes)
|
224 |
image.save(f"latest.png")
|
|
|
|
|
|
|
|
|
|
|
225 |
embed.set_image(url="attachment://latest.png")
|
226 |
await e.edit(embed=embed, attachments=[discord.File(fp=f"latest.png")])
|
227 |
os.system("rm " + f"latest.png")
|
|
|
75 |
API_URL = "https://api-inference.huggingface.co/models/" + model
|
76 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
77 |
|
78 |
+
import torch
|
79 |
+
from diffusers import StableDiffusionXLImg2ImgPipeline
|
80 |
+
from diffusers.utils import load_image
|
81 |
+
|
82 |
+
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
83 |
+
"stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
|
84 |
+
)
|
85 |
|
86 |
def generate_latex_image(latex_code):
|
87 |
api_url = "https://latex.codecogs.com/svg.latex?"
|
|
|
229 |
try: image = Image.open(io.BytesIO(image_bytes))
|
230 |
except: print(image_bytes)
|
231 |
image.save(f"latest.png")
|
232 |
+
prompt = ""
|
233 |
+
init_image = load_image(url).convert("RGB")
|
234 |
+
image = pipe(prompt, image=init_image).images[0]
|
235 |
+
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
236 |
+
image.save("latest.png")
|
237 |
embed.set_image(url="attachment://latest.png")
|
238 |
await e.edit(embed=embed, attachments=[discord.File(fp=f"latest.png")])
|
239 |
os.system("rm " + f"latest.png")
|