alvdansen commited on
Commit
3abc48f
β€’
1 Parent(s): 8d4247a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -19
app.py CHANGED
@@ -1,40 +1,26 @@
1
  import json
2
  import random
3
-
4
  import gradio as gr
5
  import numpy as np
6
  import spaces
7
  import torch
8
  from diffusers import DiffusionPipeline, LCMScheduler
 
 
9
 
 
10
  with open("sdxl_lora.json", "r") as file:
11
  data = json.load(file)
12
- sdxl_loras_raw = [
13
- {
14
- "image": item["image"],
15
- "title": item["title"],
16
- "repo": item["repo"],
17
- "trigger_word": item["trigger_word"],
18
- "weights": item["weights"],
19
- "is_pivotal": item.get("is_pivotal", False),
20
- "text_embedding_weights": item.get("text_embedding_weights", None),
21
- "likes": item.get("likes", 0),
22
- }
23
- for item in data
24
- ]
25
-
26
- # Sort the loras by likes
27
- sdxl_loras_raw = sorted(sdxl_loras_raw, key=lambda x: x["likes"], reverse=True)
28
 
29
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
30
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
31
 
32
  pipe = DiffusionPipeline.from_pretrained(model_id, variant="fp16")
33
  pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
34
- pipe.load_lora_weights("jasperai/flash-sdxl", adapter_name="lora")
35
  pipe.to(device=DEVICE, dtype=torch.float16)
36
 
37
-
38
  MAX_SEED = np.iinfo(np.int32).max
39
  MAX_IMAGE_SIZE = 1024
40
 
 
1
  import json
2
  import random
3
+ import requests
4
  import gradio as gr
5
  import numpy as np
6
  import spaces
7
  import torch
8
  from diffusers import DiffusionPipeline, LCMScheduler
9
+ from PIL import Image
10
+ import os
11
 
12
+ # Load the JSON data
13
  with open("sdxl_lora.json", "r") as file:
14
  data = json.load(file)
15
+ sdxl_loras_raw = sorted(data, key=lambda x: x["likes"], reverse=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
18
  model_id = "stabilityai/stable-diffusion-xl-base-1.0"
19
 
20
  pipe = DiffusionPipeline.from_pretrained(model_id, variant="fp16")
21
  pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
 
22
  pipe.to(device=DEVICE, dtype=torch.float16)
23
 
 
24
  MAX_SEED = np.iinfo(np.int32).max
25
  MAX_IMAGE_SIZE = 1024
26