Spaces:
Sleeping
Sleeping
Fix file extension and improve maze drawing logic
Browse filesUpdated the `weights` field in `constants.py` to use `.safetensors`.
Refactored `draw_hex_maze` by removing unused commented-out code.
Improved `draw_tri_maze` to conditionally mark the start cell `(0,0)`
with a green floor only if it exists in the maze.
- modules/constants.py +1 -1
- modules/mazlib/draw.py +5 -35
modules/constants.py
CHANGED
|
@@ -1410,7 +1410,7 @@ LORAS = [
|
|
| 1410 |
"image": "https://huggingface.co/prithivMLmods/Ton618-Space-Wallpaper-LoRA/resolve/main/images/222.png",
|
| 1411 |
"title": "Space Wallpaper",
|
| 1412 |
"repo": "prithivMLmods/Ton618-Space-Wallpaper-LoRA",
|
| 1413 |
-
"weights": "space-wallpaper-xl.
|
| 1414 |
"trigger_word": "Space Wallpaper"
|
| 1415 |
},
|
| 1416 |
#131
|
|
|
|
| 1410 |
"image": "https://huggingface.co/prithivMLmods/Ton618-Space-Wallpaper-LoRA/resolve/main/images/222.png",
|
| 1411 |
"title": "Space Wallpaper",
|
| 1412 |
"repo": "prithivMLmods/Ton618-Space-Wallpaper-LoRA",
|
| 1413 |
+
"weights": "space-wallpaper-xl.safetensors",
|
| 1414 |
"trigger_word": "Space Wallpaper"
|
| 1415 |
},
|
| 1416 |
#131
|
modules/mazlib/draw.py
CHANGED
|
@@ -103,34 +103,6 @@ def draw_hex_maze(maze, path, cell_size=45, rotation_degrees=0, save_path=None,
|
|
| 103 |
y2 = cy + cell_size*math.sin(a+math.pi/3)
|
| 104 |
d.line([(x1,y1),(x2,y2)], fill='black', width=6)
|
| 105 |
|
| 106 |
-
# force open 3 sides on the center/start hex
|
| 107 |
-
# if (0,0) in maze:
|
| 108 |
-
# cx = w//2
|
| 109 |
-
# cy = h//2
|
| 110 |
-
# for i in (0, 2, 4):
|
| 111 |
-
# a = rot + i*math.pi/3
|
| 112 |
-
# x1 = cx + cell_size*math.cos(a)
|
| 113 |
-
# y1 = cy + cell_size*math.sin(a)
|
| 114 |
-
# x2 = cx + cell_size*math.cos(a+math.pi/3)
|
| 115 |
-
# y2 = cy + cell_size*math.sin(a+math.pi/3)
|
| 116 |
-
# d.line([(x1,y1),(x2,y2)], fill='#B0B0B0', width=6)
|
| 117 |
-
# if show_doors:
|
| 118 |
-
# pts = [(cx + cell_size*math.cos(rot + i*math.pi/3),
|
| 119 |
-
# cy + cell_size*math.sin(rot + i*math.pi/3)) for i in range(2)]
|
| 120 |
-
# d.polygon(pts, outline='#B0B0B0', width=2)
|
| 121 |
-
# if show_doors:
|
| 122 |
-
# for q,r in maze: # white carve on opens
|
| 123 |
-
# cx = cell_size*1.5*q + w//2
|
| 124 |
-
# cy = cell_size*math.sqrt(3)*(r + q/2) + h//2
|
| 125 |
-
# for dq,dr in maze.get((q,r),[]):
|
| 126 |
-
# i = dirs.index((dq,dr))
|
| 127 |
-
# a = rot + i*math.pi/3
|
| 128 |
-
# x1 = cx + cell_size*math.cos(a)
|
| 129 |
-
# y1 = cy + cell_size*math.sin(a)
|
| 130 |
-
# x2 = cx + cell_size*math.cos(a+math.pi/3)
|
| 131 |
-
# y2 = cy + cell_size*math.sin(a+math.pi/3)
|
| 132 |
-
# d.line([(x1,y1),(x2,y2)], fill='white', width=1)
|
| 133 |
-
|
| 134 |
# force clear exit to outside on end cell (outer side with no neighbor)
|
| 135 |
end = max(maze, key=lambda p: abs(p[0])+abs(p[1])+abs(p[0]+p[1]))
|
| 136 |
cx = cell_size*1.5*end[0] + w//2
|
|
@@ -193,13 +165,6 @@ def draw_tri_maze(maze, path, cell=40, save_path=None, show_doors=False):
|
|
| 193 |
img_h = int(offset_y*2 + h * h_tri + 0.5)
|
| 194 |
img = Image.new('RGB', (img_w, img_h), 'white')
|
| 195 |
d = ImageDraw.Draw(img)
|
| 196 |
-
# fill start triangle (0,0) with green floor to mark the starting cell
|
| 197 |
-
try:
|
| 198 |
-
up0, v0_0, v1_0, v2_0 = cell_vertices(0, 0)
|
| 199 |
-
d.polygon([v0_0, v1_0, v2_0], fill='green')
|
| 200 |
-
except Exception:
|
| 201 |
-
# if (0,0) isn't in the expected bounds, skip filling
|
| 202 |
-
pass
|
| 203 |
|
| 204 |
def cell_vertices(x,y):
|
| 205 |
cx = offset_x + (x - min_x) * (side/2.0)
|
|
@@ -215,6 +180,11 @@ def draw_tri_maze(maze, path, cell=40, save_path=None, show_doors=False):
|
|
| 215 |
v2 = (cx + side/2.0, cy)
|
| 216 |
return up, v0, v1, v2
|
| 217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
# optional thin grey outlines for each triangle
|
| 219 |
if show_doors:
|
| 220 |
for (x,y) in maze:
|
|
|
|
| 103 |
y2 = cy + cell_size*math.sin(a+math.pi/3)
|
| 104 |
d.line([(x1,y1),(x2,y2)], fill='black', width=6)
|
| 105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
# force clear exit to outside on end cell (outer side with no neighbor)
|
| 107 |
end = max(maze, key=lambda p: abs(p[0])+abs(p[1])+abs(p[0]+p[1]))
|
| 108 |
cx = cell_size*1.5*end[0] + w//2
|
|
|
|
| 165 |
img_h = int(offset_y*2 + h * h_tri + 0.5)
|
| 166 |
img = Image.new('RGB', (img_w, img_h), 'white')
|
| 167 |
d = ImageDraw.Draw(img)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
def cell_vertices(x,y):
|
| 170 |
cx = offset_x + (x - min_x) * (side/2.0)
|
|
|
|
| 180 |
v2 = (cx + side/2.0, cy)
|
| 181 |
return up, v0, v1, v2
|
| 182 |
|
| 183 |
+
# fill start triangle (0,0) with green floor so the starting cell is visibly marked
|
| 184 |
+
if (0, 0) in maze:
|
| 185 |
+
_, v0_0, v1_0, v2_0 = cell_vertices(0, 0)
|
| 186 |
+
d.polygon([v0_0, v1_0, v2_0], fill='green')
|
| 187 |
+
|
| 188 |
# optional thin grey outlines for each triangle
|
| 189 |
if show_doors:
|
| 190 |
for (x,y) in maze:
|