Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -75,13 +75,13 @@ model = "openchat/openchat-3.5-0106"
|
|
75 |
API_URL = "https://api-inference.huggingface.co/models/" + model
|
76 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
77 |
|
78 |
-
from diffusers import StableDiffusionXLImg2ImgPipeline
|
79 |
-
from diffusers.utils import load_image
|
80 |
|
81 |
-
pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
82 |
-
"stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float32, use_safetensors=True
|
83 |
-
)
|
84 |
-
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
85 |
|
86 |
def generate_latex_image(latex_code):
|
87 |
api_url = "https://latex.codecogs.com/svg.latex?"
|
@@ -103,6 +103,12 @@ def query(x):
|
|
103 |
Response = requests.post(API_URL, headers=headers, json=x)
|
104 |
return Response.json()
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
launch_time = datetime.datetime.utcnow()
|
108 |
|
@@ -152,7 +158,11 @@ async def on_message(message:discord.Message):
|
|
152 |
print(s)
|
153 |
if message.author == client.user:
|
154 |
return
|
155 |
-
|
|
|
|
|
|
|
|
|
156 |
try:
|
157 |
with open(os.path.join(guild_name, f"{msgchannel_name}.txt"), "a") as f:
|
158 |
f.write(s)
|
|
|
75 |
API_URL = "https://api-inference.huggingface.co/models/" + model
|
76 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
77 |
|
78 |
+
# from diffusers import StableDiffusionXLImg2ImgPipeline
|
79 |
+
# from diffusers.utils import load_image
|
80 |
|
81 |
+
# pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
|
82 |
+
# "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float32, use_safetensors=True
|
83 |
+
# )
|
84 |
+
# pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
85 |
|
86 |
def generate_latex_image(latex_code):
|
87 |
api_url = "https://latex.codecogs.com/svg.latex?"
|
|
|
103 |
Response = requests.post(API_URL, headers=headers, json=x)
|
104 |
return Response.json()
|
105 |
|
106 |
+
def caption(filename):
|
107 |
+
with open(filename, "rb") as f:
|
108 |
+
data = f.read()
|
109 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
110 |
+
return response.json()
|
111 |
+
|
112 |
|
113 |
launch_time = datetime.datetime.utcnow()
|
114 |
|
|
|
158 |
print(s)
|
159 |
if message.author == client.user:
|
160 |
return
|
161 |
+
ats = []
|
162 |
+
if len(message.attachments) > 0:
|
163 |
+
for i in message.attachments:
|
164 |
+
ats.append(f"ImageInput:{i}")
|
165 |
+
s = f"GPT4 Correct {message.author}: {message.content} Images: {" ".join(ats)}<|end_of_turn|>"
|
166 |
try:
|
167 |
with open(os.path.join(guild_name, f"{msgchannel_name}.txt"), "a") as f:
|
168 |
f.write(s)
|