Spaces:
Runtime error
Runtime error
Upload 4 files
Browse files- README.md +1 -1
- genimage.py +12 -10
- llmenv.py +34 -0
- requirements.txt +1 -5
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: ππ»
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.31.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: apache-2.0
|
genimage.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
| 1 |
import spaces
|
|
|
|
| 2 |
import torch
|
| 3 |
-
import gc
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
def load_pipeline():
|
|
@@ -12,7 +19,7 @@ def load_pipeline():
|
|
| 12 |
"John6666/rae-diffusion-xl-v2-sdxl-spo-pcm",
|
| 13 |
custom_pipeline="lpw_stable_diffusion_xl",
|
| 14 |
#custom_pipeline="nyanko7/sdxl_smoothed_energy_guidance",
|
| 15 |
-
torch_dtype=torch.
|
| 16 |
)
|
| 17 |
pipe.to("cpu")
|
| 18 |
return pipe
|
|
@@ -48,10 +55,6 @@ def token_auto_concat_embeds(pipe, positive, negative):
|
|
| 48 |
|
| 49 |
|
| 50 |
def save_image(image, metadata, output_dir):
|
| 51 |
-
import os
|
| 52 |
-
import uuid
|
| 53 |
-
import json
|
| 54 |
-
from PIL import PngImagePlugin
|
| 55 |
filename = str(uuid.uuid4()) + ".png"
|
| 56 |
os.makedirs(output_dir, exist_ok=True)
|
| 57 |
filepath = os.path.join(output_dir, filename)
|
|
@@ -66,8 +69,8 @@ pipe = load_pipeline()
|
|
| 66 |
|
| 67 |
|
| 68 |
@torch.inference_mode()
|
| 69 |
-
@spaces.GPU
|
| 70 |
-
def generate_image(prompt, neg_prompt):
|
| 71 |
pipe.to(device)
|
| 72 |
prompt += ", anime, masterpiece, best quality, very aesthetic, absurdres"
|
| 73 |
neg_prompt += ", bad hands, bad feet, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], photo, deformed, disfigured, low contrast, photo, deformed, disfigured, low contrast"
|
|
@@ -91,7 +94,6 @@ def generate_image(prompt, neg_prompt):
|
|
| 91 |
output_type="pil",
|
| 92 |
clip_skip=2,
|
| 93 |
).images
|
| 94 |
-
pipe.to("cpu")
|
| 95 |
if images:
|
| 96 |
image_paths = [
|
| 97 |
save_image(image, metadata, "./outputs")
|
|
@@ -100,9 +102,9 @@ def generate_image(prompt, neg_prompt):
|
|
| 100 |
return image_paths
|
| 101 |
except Exception as e:
|
| 102 |
print(e)
|
| 103 |
-
pipe.to("cpu")
|
| 104 |
return []
|
| 105 |
finally:
|
|
|
|
| 106 |
torch.cuda.empty_cache()
|
| 107 |
gc.collect()
|
| 108 |
|
|
|
|
| 1 |
import spaces
|
| 2 |
+
import gradio as gr
|
| 3 |
import torch
|
| 4 |
+
import gc, os, uuid, json
|
| 5 |
+
from PIL import PngImagePlugin
|
| 6 |
|
| 7 |
|
| 8 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 9 |
+
if os.getenv("SPACES_ZERO_GPU", None):
|
| 10 |
+
torch.backends.cudnn.deterministic = True
|
| 11 |
+
torch.backends.cudnn.benchmark = False
|
| 12 |
+
torch.backends.cuda.matmul.allow_tf32 = True
|
| 13 |
+
torch.set_float32_matmul_precision("high") # https://pytorch.org/blog/accelerating-generative-ai-3/
|
| 14 |
|
| 15 |
|
| 16 |
def load_pipeline():
|
|
|
|
| 19 |
"John6666/rae-diffusion-xl-v2-sdxl-spo-pcm",
|
| 20 |
custom_pipeline="lpw_stable_diffusion_xl",
|
| 21 |
#custom_pipeline="nyanko7/sdxl_smoothed_energy_guidance",
|
| 22 |
+
torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
|
| 23 |
)
|
| 24 |
pipe.to("cpu")
|
| 25 |
return pipe
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
def save_image(image, metadata, output_dir):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
filename = str(uuid.uuid4()) + ".png"
|
| 59 |
os.makedirs(output_dir, exist_ok=True)
|
| 60 |
filepath = os.path.join(output_dir, filename)
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
@torch.inference_mode()
|
| 72 |
+
@spaces.GPU(duration=10)
|
| 73 |
+
def generate_image(prompt, neg_prompt, progress=gr.Progress(track_tqdm=True)):
|
| 74 |
pipe.to(device)
|
| 75 |
prompt += ", anime, masterpiece, best quality, very aesthetic, absurdres"
|
| 76 |
neg_prompt += ", bad hands, bad feet, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], photo, deformed, disfigured, low contrast, photo, deformed, disfigured, low contrast"
|
|
|
|
| 94 |
output_type="pil",
|
| 95 |
clip_skip=2,
|
| 96 |
).images
|
|
|
|
| 97 |
if images:
|
| 98 |
image_paths = [
|
| 99 |
save_image(image, metadata, "./outputs")
|
|
|
|
| 102 |
return image_paths
|
| 103 |
except Exception as e:
|
| 104 |
print(e)
|
|
|
|
| 105 |
return []
|
| 106 |
finally:
|
| 107 |
+
pipe.to("cpu")
|
| 108 |
torch.cuda.empty_cache()
|
| 109 |
gc.collect()
|
| 110 |
|
llmenv.py
CHANGED
|
@@ -14,6 +14,7 @@ llm_models = {
|
|
| 14 |
"mn-12b-lyra-v2a1-q5_k_m.gguf": ["HalleyStarbun/MN-12B-Lyra-v2a1-Q5_K_M-GGUF", MessagesFormatterType.CHATML],
|
| 15 |
"L3-8B-Tamamo-v1.i1-Q5_K_M.gguf": ["mradermacher/L3-8B-Tamamo-v1-i1-GGUF", MessagesFormatterType.LLAMA_3],
|
| 16 |
"MN-Chinofun-12B-2.i1-Q4_K_M.gguf": ["mradermacher/MN-Chinofun-12B-2-i1-GGUF", MessagesFormatterType.MISTRAL],
|
|
|
|
| 17 |
"Dolphin-5.1-7b.Q5_K_M.gguf": ["mradermacher/Dolphin-5.1-7b-GGUF", MessagesFormatterType.MISTRAL],
|
| 18 |
"Captain-Eris-Diogenes_Twighlight-V0.420-12B.i1-Q4_K_M.gguf": ["mradermacher/Captain-Eris-Diogenes_Twighlight-V0.420-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
|
| 19 |
"Captain-Eris-Diogenes_Twilight-V0.420-12B.i1-Q4_K_M.gguf": ["mradermacher/Captain-Eris-Diogenes_Twilight-V0.420-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
|
|
@@ -144,6 +145,9 @@ llm_models = {
|
|
| 144 |
"MagnaMellRei-v1-12B.Q4_K_M.gguf": ["mradermacher/MagnaMellRei-v1-12B-GGUF", MessagesFormatterType.CHATML],
|
| 145 |
"HMS-Slerp-12B.Q4_K_M.gguf": ["mradermacher/HMS-Slerp-12B-GGUF", MessagesFormatterType.CHATML],
|
| 146 |
"SnowElf-12B-v2.Q4_K_M.gguf": ["mradermacher/SnowElf-12B-v2-GGUF", MessagesFormatterType.CHATML],
|
|
|
|
|
|
|
|
|
|
| 147 |
"Protestant-Christian-Bible-Expert-v2.0-12B.Q4_K_M.gguf": ["mradermacher/Protestant-Christian-Bible-Expert-v2.0-12B-GGUF", MessagesFormatterType.MISTRAL],
|
| 148 |
"openbuddy-qwen2.5llamaify-14b-v23.1-200k.i1-Q4_K_M.gguf": ["mradermacher/openbuddy-qwen2.5llamaify-14b-v23.1-200k-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 149 |
"Trinas_Nectar-8B-model_stock.i1-Q4_K_M.gguf": ["mradermacher/Trinas_Nectar-8B-model_stock-i1-GGUF", MessagesFormatterType.MISTRAL],
|
|
@@ -158,6 +162,36 @@ llm_models = {
|
|
| 158 |
#"": ["", MessagesFormatterType.OPEN_CHAT],
|
| 159 |
#"": ["", MessagesFormatterType.CHATML],
|
| 160 |
#"": ["", MessagesFormatterType.PHI_3],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
"vanilla-cn-roleplay-0.1.Q5_K_M.gguf": ["mradermacher/vanilla-cn-roleplay-0.1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 162 |
"EsotericLight-12B.Q4_K_M.gguf": ["mradermacher/EsotericLight-12B-GGUF", MessagesFormatterType.CHATML],
|
| 163 |
"llama-3-Daredevil-Mahou-8B.Q5_K_M.gguf": ["mradermacher/llama-3-Daredevil-Mahou-8B-GGUF", MessagesFormatterType.LLAMA_3],
|
|
|
|
| 14 |
"mn-12b-lyra-v2a1-q5_k_m.gguf": ["HalleyStarbun/MN-12B-Lyra-v2a1-Q5_K_M-GGUF", MessagesFormatterType.CHATML],
|
| 15 |
"L3-8B-Tamamo-v1.i1-Q5_K_M.gguf": ["mradermacher/L3-8B-Tamamo-v1-i1-GGUF", MessagesFormatterType.LLAMA_3],
|
| 16 |
"MN-Chinofun-12B-2.i1-Q4_K_M.gguf": ["mradermacher/MN-Chinofun-12B-2-i1-GGUF", MessagesFormatterType.MISTRAL],
|
| 17 |
+
"Shirayukihime-12B.Q4_K_M.gguf": ["mradermacher/Shirayukihime-12B-GGUF", MessagesFormatterType.CHATML],
|
| 18 |
"Dolphin-5.1-7b.Q5_K_M.gguf": ["mradermacher/Dolphin-5.1-7b-GGUF", MessagesFormatterType.MISTRAL],
|
| 19 |
"Captain-Eris-Diogenes_Twighlight-V0.420-12B.i1-Q4_K_M.gguf": ["mradermacher/Captain-Eris-Diogenes_Twighlight-V0.420-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
|
| 20 |
"Captain-Eris-Diogenes_Twilight-V0.420-12B.i1-Q4_K_M.gguf": ["mradermacher/Captain-Eris-Diogenes_Twilight-V0.420-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
|
|
|
|
| 145 |
"MagnaMellRei-v1-12B.Q4_K_M.gguf": ["mradermacher/MagnaMellRei-v1-12B-GGUF", MessagesFormatterType.CHATML],
|
| 146 |
"HMS-Slerp-12B.Q4_K_M.gguf": ["mradermacher/HMS-Slerp-12B-GGUF", MessagesFormatterType.CHATML],
|
| 147 |
"SnowElf-12B-v2.Q4_K_M.gguf": ["mradermacher/SnowElf-12B-v2-GGUF", MessagesFormatterType.CHATML],
|
| 148 |
+
"KnowledgeCore-12B.Q4_K_M.gguf": ["mradermacher/KnowledgeCore-12B-GGUF", MessagesFormatterType.CHATML],
|
| 149 |
+
"BianCang-Qwen2.5-14B-Instruct.Q4_K_M.gguf": ["mradermacher/BianCang-Qwen2.5-14B-Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 150 |
+
"Gemma-2-Llama-Swallow-9b-pt-v0.1.Q4_K_M.gguf": ["mradermacher/Gemma-2-Llama-Swallow-9b-pt-v0.1-GGUF", MessagesFormatterType.ALPACA],
|
| 151 |
"Protestant-Christian-Bible-Expert-v2.0-12B.Q4_K_M.gguf": ["mradermacher/Protestant-Christian-Bible-Expert-v2.0-12B-GGUF", MessagesFormatterType.MISTRAL],
|
| 152 |
"openbuddy-qwen2.5llamaify-14b-v23.1-200k.i1-Q4_K_M.gguf": ["mradermacher/openbuddy-qwen2.5llamaify-14b-v23.1-200k-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 153 |
"Trinas_Nectar-8B-model_stock.i1-Q4_K_M.gguf": ["mradermacher/Trinas_Nectar-8B-model_stock-i1-GGUF", MessagesFormatterType.MISTRAL],
|
|
|
|
| 162 |
#"": ["", MessagesFormatterType.OPEN_CHAT],
|
| 163 |
#"": ["", MessagesFormatterType.CHATML],
|
| 164 |
#"": ["", MessagesFormatterType.PHI_3],
|
| 165 |
+
"TutorRL-7B.Q5_K_M.gguf": ["mradermacher/TutorRL-7B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 166 |
+
"Omega-Darker_The-Final-Directive-14B.Q4_K_M.gguf": ["mradermacher/Omega-Darker_The-Final-Directive-14B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 167 |
+
"Student-rl_Qwen2.5-7B-Instruct_v0.0.1.Q5_K_M.gguf": ["mradermacher/Student-rl_Qwen2.5-7B-Instruct_v0.0.1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 168 |
+
"Contrl-Stheno-v1-8B.Q5_K_M.gguf": ["mradermacher/Contrl-Stheno-v1-8B-GGUF", MessagesFormatterType.LLAMA_3],
|
| 169 |
+
"fluxiia_14b.Q4_K_M.gguf": ["mradermacher/fluxiia_14b-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 170 |
+
"JwenJwen1-1.5b.Q5_K_M.gguf": ["mradermacher/JwenJwen1-1.5b-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 171 |
+
"SecGPT-14B-Reasoning.Q4_K_M.gguf": ["mradermacher/SecGPT-14B-Reasoning-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 172 |
+
"Dirty-Muse-Writer-v01-Uncensored-Erotica-NSFW.Q4_K_M.gguf": ["mradermacher/Dirty-Muse-Writer-v01-Uncensored-Erotica-NSFW-GGUF", MessagesFormatterType.ALPACA],
|
| 173 |
+
"SearchR1-nq_hotpotqa_train-qwen2.5-7b-em-ppo.Q4_K_M.gguf": ["mradermacher/SearchR1-nq_hotpotqa_train-qwen2.5-7b-em-ppo-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 174 |
+
"ForgottenMaid-12B-v2.Q4_K_M.gguf": ["mradermacher/ForgottenMaid-12B-v2-GGUF", MessagesFormatterType.MISTRAL],
|
| 175 |
+
"Socratic-Qwen2.5-7B-v2.Q5_K_M.gguf": ["mradermacher/Socratic-Qwen2.5-7B-v2-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 176 |
+
"EsotericSage-12B.i1-Q4_K_M.gguf": ["mradermacher/EsotericSage-12B-i1-GGUF", MessagesFormatterType.MISTRAL],
|
| 177 |
+
"praxis-bookwriter-llama3.1-8b-sft.Q5_K_M.gguf": ["mradermacher/praxis-bookwriter-llama3.1-8b-sft-GGUF", MessagesFormatterType.LLAMA_3],
|
| 178 |
+
"LinearWriter-12B.Q4_K_M.gguf": ["mradermacher/LinearWriter-12B-GGUF", MessagesFormatterType.MISTRAL],
|
| 179 |
+
"Qwen2.5-CoderX-14B-v0.5.Q4_K_M.gguf": ["mradermacher/Qwen2.5-CoderX-14B-v0.5-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 180 |
+
"Violet_MagCap-Rebase-12B.Q4_K_M.gguf": ["mradermacher/Violet_MagCap-Rebase-12B-GGUF", MessagesFormatterType.MISTRAL],
|
| 181 |
+
"VeriReason-Qwen2.5-7b-SFT-Reasoning.i1-Q5_K_M.gguf": ["mradermacher/VeriReason-Qwen2.5-7b-SFT-Reasoning-i1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 182 |
+
"Emilia-Multislerp-12B.Q4_K_M.gguf": ["mradermacher/Emilia-Multislerp-12B-GGUF", MessagesFormatterType.CHATML],
|
| 183 |
+
"TaskRouter-1.5B.Q5_K_M.gguf": ["mradermacher/TaskRouter-1.5B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 184 |
+
"NeonMaid-12B-v2.Q4_K_M.gguf": ["mradermacher/NeonMaid-12B-v2-GGUF", MessagesFormatterType.CHATML],
|
| 185 |
+
"Orihime-Gutenberg-12B.Q4_K_M.gguf": ["mradermacher/Orihime-Gutenberg-12B-GGUF", MessagesFormatterType.CHATML],
|
| 186 |
+
"SearchSimulation_3B.Q5_K_M.gguf": ["mradermacher/SearchSimulation_3B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 187 |
+
"SearchSimulation_14B.Q4_K_M.gguf": ["mradermacher/SearchSimulation_14B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 188 |
+
"NeonMaid-12B.Q4_K_M.gguf": ["mradermacher/NeonMaid-12B-GGUF", MessagesFormatterType.CHATML],
|
| 189 |
+
"Chief_chain_generator-Qwen2.5-7B-Instruct.Q5_K_M.gguf": ["mradermacher/Chief_chain_generator-Qwen2.5-7B-Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 190 |
+
"Emotion_inferencer-Qwen2.5-7B-Instruct.Q5_K_M.gguf": ["mradermacher/Emotion_inferencer-Qwen2.5-7B-Instruct-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 191 |
+
"ForgottenMaid-12B.Q4_K_M.gguf": ["mradermacher/ForgottenMaid-12B-GGUF", MessagesFormatterType.MISTRAL],
|
| 192 |
+
"AceCoder-Qwen2.5-Coder-7B-Ins-V1.1.Q5_K_M.gguf": ["mradermacher/AceCoder-Qwen2.5-Coder-7B-Ins-V1.1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 193 |
+
"TheDrummer_Rivermind-Lux-12B-v1-Q4_K_M.gguf": ["bartowski/TheDrummer_Rivermind-Lux-12B-v1-GGUF", MessagesFormatterType.MISTRAL],
|
| 194 |
+
"Qwen2.5-GenX-14B.Q4_K_M.gguf": ["mradermacher/Qwen2.5-GenX-14B-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 195 |
"vanilla-cn-roleplay-0.1.Q5_K_M.gguf": ["mradermacher/vanilla-cn-roleplay-0.1-GGUF", MessagesFormatterType.OPEN_CHAT],
|
| 196 |
"EsotericLight-12B.Q4_K_M.gguf": ["mradermacher/EsotericLight-12B-GGUF", MessagesFormatterType.CHATML],
|
| 197 |
"llama-3-Daredevil-Mahou-8B.Q5_K_M.gguf": ["mradermacher/llama-3-Daredevil-Mahou-8B-GGUF", MessagesFormatterType.LLAMA_3],
|
requirements.txt
CHANGED
|
@@ -3,15 +3,11 @@ huggingface_hub
|
|
| 3 |
hf_xet
|
| 4 |
hf_transfer
|
| 5 |
scikit-build-core
|
| 6 |
-
#https://github.com/abetlen/llama-cpp-python/releases/download/v0.2.90-cu124/llama_cpp_python-0.2.90-cp310-cp310-linux_x86_64.whl
|
| 7 |
https://github.com/abetlen/llama-cpp-python/releases/download/v0.3.4-cu124/llama_cpp_python-0.3.4-cp310-cp310-linux_x86_64.whl
|
| 8 |
git+https://github.com/Maximilian-Winter/llama-cpp-agent
|
| 9 |
pybind11>=2.12
|
| 10 |
torch==2.4.0
|
| 11 |
torchvision
|
| 12 |
-
torchao>=0.9.0
|
| 13 |
-
triton
|
| 14 |
-
xformers
|
| 15 |
accelerate
|
| 16 |
transformers<=4.48.3
|
| 17 |
optimum[onnxruntime]
|
|
@@ -22,4 +18,4 @@ rapidfuzz
|
|
| 22 |
wrapt-timeout-decorator
|
| 23 |
opencv-python
|
| 24 |
numpy<2
|
| 25 |
-
pydantic==2.10.6
|
|
|
|
| 3 |
hf_xet
|
| 4 |
hf_transfer
|
| 5 |
scikit-build-core
|
|
|
|
| 6 |
https://github.com/abetlen/llama-cpp-python/releases/download/v0.3.4-cu124/llama_cpp_python-0.3.4-cp310-cp310-linux_x86_64.whl
|
| 7 |
git+https://github.com/Maximilian-Winter/llama-cpp-agent
|
| 8 |
pybind11>=2.12
|
| 9 |
torch==2.4.0
|
| 10 |
torchvision
|
|
|
|
|
|
|
|
|
|
| 11 |
accelerate
|
| 12 |
transformers<=4.48.3
|
| 13 |
optimum[onnxruntime]
|
|
|
|
| 18 |
wrapt-timeout-decorator
|
| 19 |
opencv-python
|
| 20 |
numpy<2
|
| 21 |
+
pydantic==2.10.6
|