Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,13 +4,13 @@ from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, U
|
|
| 4 |
from datasets import load_dataset
|
| 5 |
from torch.utils.data import DataLoader
|
| 6 |
from torchvision import transforms
|
| 7 |
-
|
| 8 |
css = "* {font-family: sans-serif;} .gradio-container {max-width:950px!important; padding:10px!important;} .box {background:#161b22!important; border:1px solid #30363d!important; border-radius:8px!important; padding:12px!important;} .btn {background:linear-gradient(135deg,#2563eb,#1d4ed8)!important; color:white!important; font-weight:600!important;} input, select, textarea {background:#0d1117!important; color:#fff!important; border:1px solid #30363d!important;}"
|
| 9 |
pipe, logs = None, []
|
| 10 |
|
| 11 |
def log(msg): global logs; logs.append(f"[{time.strftime('%H:%M:%S')}] {msg}")
|
| 12 |
def get_logs(): return "\n".join(logs)
|
| 13 |
-
|
| 14 |
def train_from_scratch(token, repo, epochs, lr, batch_size):
|
| 15 |
global pipe, logs
|
| 16 |
logs = []
|
|
@@ -65,7 +65,7 @@ def train_from_scratch(token, repo, epochs, lr, batch_size):
|
|
| 65 |
def start_train(t, r, e, l, b):
|
| 66 |
threading.Thread(target=train_from_scratch, args=(t, r, e, l, b)).start()
|
| 67 |
return "Initialisation de l'architecture vierge..."
|
| 68 |
-
|
| 69 |
def generate(prompt, neg, steps, cfg, w, h, img=None, strg=0.75):
|
| 70 |
global pipe
|
| 71 |
if pipe is None: return None, "Veuillez d'abord entraîner le modèle ou initialiser l'état."
|
|
|
|
| 4 |
from datasets import load_dataset
|
| 5 |
from torch.utils.data import DataLoader
|
| 6 |
from torchvision import transforms
|
| 7 |
+
import spaces
|
| 8 |
css = "* {font-family: sans-serif;} .gradio-container {max-width:950px!important; padding:10px!important;} .box {background:#161b22!important; border:1px solid #30363d!important; border-radius:8px!important; padding:12px!important;} .btn {background:linear-gradient(135deg,#2563eb,#1d4ed8)!important; color:white!important; font-weight:600!important;} input, select, textarea {background:#0d1117!important; color:#fff!important; border:1px solid #30363d!important;}"
|
| 9 |
pipe, logs = None, []
|
| 10 |
|
| 11 |
def log(msg): global logs; logs.append(f"[{time.strftime('%H:%M:%S')}] {msg}")
|
| 12 |
def get_logs(): return "\n".join(logs)
|
| 13 |
+
@spaces.GPU
|
| 14 |
def train_from_scratch(token, repo, epochs, lr, batch_size):
|
| 15 |
global pipe, logs
|
| 16 |
logs = []
|
|
|
|
| 65 |
def start_train(t, r, e, l, b):
|
| 66 |
threading.Thread(target=train_from_scratch, args=(t, r, e, l, b)).start()
|
| 67 |
return "Initialisation de l'architecture vierge..."
|
| 68 |
+
@spaces.GPU
|
| 69 |
def generate(prompt, neg, steps, cfg, w, h, img=None, strg=0.75):
|
| 70 |
global pipe
|
| 71 |
if pipe is None: return None, "Veuillez d'abord entraîner le modèle ou initialiser l'état."
|