Spaces:
Sleeping
Sleeping
Commit
·
0106bb4
1
Parent(s):
7a1d414
added multiple models
Browse files- src/assets/history/entries/027d2413-fbd2-4a24-9ff7-98fc8d3e80c9.json +15 -0
- src/assets/history/entries/06fafc3a-ab60-4485-ae4c-b4b02d7e9674.json +16 -0
- src/assets/history/entries/139c06d9-13ce-4a83-8771-507a02278524.json +15 -0
- src/assets/history/entries/2112d860-c83a-40b9-af44-8dffe4464e34.json +15 -0
- src/assets/history/entries/33f3345e-f96d-4639-ad6a-f1f29639ace4.json +15 -0
- src/assets/history/entries/3e91c2d6-f541-48a5-a29c-726bb7317a78.json +15 -0
- src/assets/history/entries/620beb14-a3bc-40e8-84fc-f235b542ba61.json +15 -0
- src/assets/history/entries/74f4e171-ec11-4079-be63-1bac1208aa8b.json +16 -0
- src/assets/history/entries/950520f5-b9ff-49e2-86a2-ff63ebe41e92.json +15 -0
- src/assets/history/entries/abef507b-ce60-41ed-a4fb-4e9c17e3df86.json +15 -0
- src/assets/history/entries/b13132cf-6915-47d2-b86c-9a7fe59cd11d.json +15 -0
- src/assets/history/entries/cd919b62-6d02-43b0-8233-65db1976aae5.json +15 -0
- src/assets/history/entries/e00c8028-63d1-40a7-8504-e1a447538fe1.json +15 -0
- src/assets/history/entries/e093f3e1-0d76-4fd6-b16e-478effbcd711.json +15 -0
- src/assets/history/index.json +140 -0
- src/sdgen/config/settings.py +2 -1
- src/sdgen/main.py +29 -15
- src/sdgen/presets/styles.py +5 -35
- src/sdgen/sd/img2img.py +2 -2
- src/sdgen/sd/pipeline.py +16 -6
- src/sdgen/ui/layout.py +56 -12
- src/sdgen/ui/tabs/history_tab.py +4 -5
- src/sdgen/ui/tabs/img2img_tab.py +9 -3
- src/sdgen/ui/tabs/presets_tab.py +0 -27
- src/sdgen/ui/tabs/txt2img_tab.py +5 -5
src/assets/history/entries/027d2413-fbd2-4a24-9ff7-98fc8d3e80c9.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 40,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 768,
|
| 9 |
+
"seed": 7956870375603612926,
|
| 10 |
+
"elapsed_seconds": 202.7896490097046,
|
| 11 |
+
"timestamp": "2025-12-04T14:22:51.556788",
|
| 12 |
+
"id": "027d2413-fbd2-4a24-9ff7-98fc8d3e80c9",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/027d2413-fbd2-4a24-9ff7-98fc8d3e80c9.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/027d2413-fbd2-4a24-9ff7-98fc8d3e80c9.png"
|
| 15 |
+
}
|
src/assets/history/entries/06fafc3a-ab60-4485-ae4c-b4b02d7e9674.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "img2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 40,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 384,
|
| 8 |
+
"height": 384,
|
| 9 |
+
"seed": 508343615982598748,
|
| 10 |
+
"strength": 0.6,
|
| 11 |
+
"elapsed_seconds": 35.82293701171875,
|
| 12 |
+
"timestamp": "2025-12-04T14:16:04.829771",
|
| 13 |
+
"id": "06fafc3a-ab60-4485-ae4c-b4b02d7e9674",
|
| 14 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/06fafc3a-ab60-4485-ae4c-b4b02d7e9674.png",
|
| 15 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/06fafc3a-ab60-4485-ae4c-b4b02d7e9674.png"
|
| 16 |
+
}
|
src/assets/history/entries/139c06d9-13ce-4a83-8771-507a02278524.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 4 |
+
"negative_prompt": "blurry, low detail, mutation, deformed",
|
| 5 |
+
"steps": 25,
|
| 6 |
+
"guidance_scale": 7.0,
|
| 7 |
+
"width": 448,
|
| 8 |
+
"height": 448,
|
| 9 |
+
"seed": 7658870821531991741,
|
| 10 |
+
"elapsed_seconds": 7.105409383773804,
|
| 11 |
+
"timestamp": "2025-12-04T13:24:58.460595",
|
| 12 |
+
"id": "139c06d9-13ce-4a83-8771-507a02278524",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/139c06d9-13ce-4a83-8771-507a02278524.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/139c06d9-13ce-4a83-8771-507a02278524.png"
|
| 15 |
+
}
|
src/assets/history/entries/2112d860-c83a-40b9-af44-8dffe4464e34.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 10,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 40003955912794948,
|
| 10 |
+
"elapsed_seconds": 35.98195815086365,
|
| 11 |
+
"timestamp": "2025-12-04T14:48:38.501230",
|
| 12 |
+
"id": "2112d860-c83a-40b9-af44-8dffe4464e34",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/2112d860-c83a-40b9-af44-8dffe4464e34.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/2112d860-c83a-40b9-af44-8dffe4464e34.png"
|
| 15 |
+
}
|
src/assets/history/entries/33f3345e-f96d-4639-ad6a-f1f29639ace4.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 4 |
+
"negative_prompt": "blurry, low detail, mutation, deformed",
|
| 5 |
+
"steps": 26,
|
| 6 |
+
"guidance_scale": 7.0,
|
| 7 |
+
"width": 448,
|
| 8 |
+
"height": 448,
|
| 9 |
+
"seed": 5403877172223779031,
|
| 10 |
+
"elapsed_seconds": 7.454399347305298,
|
| 11 |
+
"timestamp": "2025-12-04T13:27:43.827963",
|
| 12 |
+
"id": "33f3345e-f96d-4639-ad6a-f1f29639ace4",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/33f3345e-f96d-4639-ad6a-f1f29639ace4.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/33f3345e-f96d-4639-ad6a-f1f29639ace4.png"
|
| 15 |
+
}
|
src/assets/history/entries/3e91c2d6-f541-48a5-a29c-726bb7317a78.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 4 |
+
"negative_prompt": "blurry, low detail, mutation, deformed",
|
| 5 |
+
"steps": 30,
|
| 6 |
+
"guidance_scale": 8.0,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 7883419924506962153,
|
| 10 |
+
"elapsed_seconds": 93.77058839797974,
|
| 11 |
+
"timestamp": "2025-12-04T14:13:49.558903",
|
| 12 |
+
"id": "3e91c2d6-f541-48a5-a29c-726bb7317a78",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/3e91c2d6-f541-48a5-a29c-726bb7317a78.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/3e91c2d6-f541-48a5-a29c-726bb7317a78.png"
|
| 15 |
+
}
|
src/assets/history/entries/620beb14-a3bc-40e8-84fc-f235b542ba61.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 40,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 768,
|
| 9 |
+
"seed": 7450002424425761588,
|
| 10 |
+
"elapsed_seconds": 209.31288957595825,
|
| 11 |
+
"timestamp": "2025-12-04T14:09:31.084861",
|
| 12 |
+
"id": "620beb14-a3bc-40e8-84fc-f235b542ba61",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/620beb14-a3bc-40e8-84fc-f235b542ba61.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/620beb14-a3bc-40e8-84fc-f235b542ba61.png"
|
| 15 |
+
}
|
src/assets/history/entries/74f4e171-ec11-4079-be63-1bac1208aa8b.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "img2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 40,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 384,
|
| 8 |
+
"height": 384,
|
| 9 |
+
"seed": 9140586117572609520,
|
| 10 |
+
"strength": 0.6,
|
| 11 |
+
"elapsed_seconds": 38.3564293384552,
|
| 12 |
+
"timestamp": "2025-12-04T16:40:47.138533",
|
| 13 |
+
"id": "74f4e171-ec11-4079-be63-1bac1208aa8b",
|
| 14 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/74f4e171-ec11-4079-be63-1bac1208aa8b.png",
|
| 15 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/74f4e171-ec11-4079-be63-1bac1208aa8b.png"
|
| 16 |
+
}
|
src/assets/history/entries/950520f5-b9ff-49e2-86a2-ff63ebe41e92.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "ultra realistic, 35mm photography, photorealistic, cinematic lighting",
|
| 4 |
+
"negative_prompt": "low quality, blurry, deformed, extra limbs",
|
| 5 |
+
"steps": 28,
|
| 6 |
+
"guidance_scale": 7.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 1390214708901413353,
|
| 10 |
+
"elapsed_seconds": 85.99510884284973,
|
| 11 |
+
"timestamp": "2025-12-04T13:57:18.478626",
|
| 12 |
+
"id": "950520f5-b9ff-49e2-86a2-ff63ebe41e92",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/950520f5-b9ff-49e2-86a2-ff63ebe41e92.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/950520f5-b9ff-49e2-86a2-ff63ebe41e92.png"
|
| 15 |
+
}
|
src/assets/history/entries/abef507b-ce60-41ed-a4fb-4e9c17e3df86.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 6,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 768,
|
| 9 |
+
"seed": 7238946422616423766,
|
| 10 |
+
"elapsed_seconds": 40.70923161506653,
|
| 11 |
+
"timestamp": "2025-12-04T16:31:14.247688",
|
| 12 |
+
"id": "abef507b-ce60-41ed-a4fb-4e9c17e3df86",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/abef507b-ce60-41ed-a4fb-4e9c17e3df86.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/abef507b-ce60-41ed-a4fb-4e9c17e3df86.png"
|
| 15 |
+
}
|
src/assets/history/entries/b13132cf-6915-47d2-b86c-9a7fe59cd11d.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 4 |
+
"negative_prompt": "oversaturated, low detail, flat lighting",
|
| 5 |
+
"steps": 30,
|
| 6 |
+
"guidance_scale": 7.0,
|
| 7 |
+
"width": 768,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 6475212377733185643,
|
| 10 |
+
"elapsed_seconds": 20.65937638282776,
|
| 11 |
+
"timestamp": "2025-12-04T13:27:30.835543",
|
| 12 |
+
"id": "b13132cf-6915-47d2-b86c-9a7fe59cd11d",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/b13132cf-6915-47d2-b86c-9a7fe59cd11d.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/b13132cf-6915-47d2-b86c-9a7fe59cd11d.png"
|
| 15 |
+
}
|
src/assets/history/entries/cd919b62-6d02-43b0-8233-65db1976aae5.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 4 |
+
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 5 |
+
"steps": 20,
|
| 6 |
+
"guidance_scale": 8.5,
|
| 7 |
+
"width": 512,
|
| 8 |
+
"height": 768,
|
| 9 |
+
"seed": 6204994568325223347,
|
| 10 |
+
"elapsed_seconds": 105.84215068817139,
|
| 11 |
+
"timestamp": "2025-12-04T16:30:15.167704",
|
| 12 |
+
"id": "cd919b62-6d02-43b0-8233-65db1976aae5",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/cd919b62-6d02-43b0-8233-65db1976aae5.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/cd919b62-6d02-43b0-8233-65db1976aae5.png"
|
| 15 |
+
}
|
src/assets/history/entries/e00c8028-63d1-40a7-8504-e1a447538fe1.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 4 |
+
"negative_prompt": "oversaturated, low detail, flat lighting",
|
| 5 |
+
"steps": 30,
|
| 6 |
+
"guidance_scale": 7.0,
|
| 7 |
+
"width": 768,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 6882939413923257663,
|
| 10 |
+
"elapsed_seconds": 20.79175043106079,
|
| 11 |
+
"timestamp": "2025-12-04T13:29:35.384099",
|
| 12 |
+
"id": "e00c8028-63d1-40a7-8504-e1a447538fe1",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/e00c8028-63d1-40a7-8504-e1a447538fe1.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/e00c8028-63d1-40a7-8504-e1a447538fe1.png"
|
| 15 |
+
}
|
src/assets/history/entries/e093f3e1-0d76-4fd6-b16e-478effbcd711.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mode": "txt2img",
|
| 3 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 4 |
+
"negative_prompt": "oversaturated, low detail, flat lighting",
|
| 5 |
+
"steps": 30,
|
| 6 |
+
"guidance_scale": 7.0,
|
| 7 |
+
"width": 768,
|
| 8 |
+
"height": 512,
|
| 9 |
+
"seed": 2484357327948880929,
|
| 10 |
+
"elapsed_seconds": 160.33333945274353,
|
| 11 |
+
"timestamp": "2025-12-04T13:38:22.075875",
|
| 12 |
+
"id": "e093f3e1-0d76-4fd6-b16e-478effbcd711",
|
| 13 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/e093f3e1-0d76-4fd6-b16e-478effbcd711.png",
|
| 14 |
+
"full_image": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/full/e093f3e1-0d76-4fd6-b16e-478effbcd711.png"
|
| 15 |
+
}
|
src/assets/history/index.json
CHANGED
|
@@ -1,4 +1,144 @@
|
|
| 1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
{
|
| 3 |
"id": "a6861b54-0afb-4b32-bb33-cacdadd7e639",
|
| 4 |
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
|
|
|
| 1 |
[
|
| 2 |
+
{
|
| 3 |
+
"id": "74f4e171-ec11-4079-be63-1bac1208aa8b",
|
| 4 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 5 |
+
"mode": "img2img",
|
| 6 |
+
"seed": 9140586117572609520,
|
| 7 |
+
"width": 384,
|
| 8 |
+
"height": 384,
|
| 9 |
+
"timestamp": "2025-12-04T16:40:47.138533",
|
| 10 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/74f4e171-ec11-4079-be63-1bac1208aa8b.png"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"id": "abef507b-ce60-41ed-a4fb-4e9c17e3df86",
|
| 14 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 15 |
+
"mode": "txt2img",
|
| 16 |
+
"seed": 7238946422616423766,
|
| 17 |
+
"width": 512,
|
| 18 |
+
"height": 768,
|
| 19 |
+
"timestamp": "2025-12-04T16:31:14.247688",
|
| 20 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/abef507b-ce60-41ed-a4fb-4e9c17e3df86.png"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"id": "cd919b62-6d02-43b0-8233-65db1976aae5",
|
| 24 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 25 |
+
"mode": "txt2img",
|
| 26 |
+
"seed": 6204994568325223347,
|
| 27 |
+
"width": 512,
|
| 28 |
+
"height": 768,
|
| 29 |
+
"timestamp": "2025-12-04T16:30:15.167704",
|
| 30 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/cd919b62-6d02-43b0-8233-65db1976aae5.png"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"id": "2112d860-c83a-40b9-af44-8dffe4464e34",
|
| 34 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 35 |
+
"mode": "txt2img",
|
| 36 |
+
"seed": 40003955912794948,
|
| 37 |
+
"width": 512,
|
| 38 |
+
"height": 512,
|
| 39 |
+
"timestamp": "2025-12-04T14:48:38.501230",
|
| 40 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/2112d860-c83a-40b9-af44-8dffe4464e34.png"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"id": "027d2413-fbd2-4a24-9ff7-98fc8d3e80c9",
|
| 44 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 45 |
+
"mode": "txt2img",
|
| 46 |
+
"seed": 7956870375603612926,
|
| 47 |
+
"width": 512,
|
| 48 |
+
"height": 768,
|
| 49 |
+
"timestamp": "2025-12-04T14:22:51.556788",
|
| 50 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/027d2413-fbd2-4a24-9ff7-98fc8d3e80c9.png"
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"id": "06fafc3a-ab60-4485-ae4c-b4b02d7e9674",
|
| 54 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 55 |
+
"mode": "img2img",
|
| 56 |
+
"seed": 508343615982598748,
|
| 57 |
+
"width": 384,
|
| 58 |
+
"height": 384,
|
| 59 |
+
"timestamp": "2025-12-04T14:16:04.829771",
|
| 60 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/06fafc3a-ab60-4485-ae4c-b4b02d7e9674.png"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"id": "3e91c2d6-f541-48a5-a29c-726bb7317a78",
|
| 64 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 65 |
+
"mode": "txt2img",
|
| 66 |
+
"seed": 7883419924506962153,
|
| 67 |
+
"width": 512,
|
| 68 |
+
"height": 512,
|
| 69 |
+
"timestamp": "2025-12-04T14:13:49.558903",
|
| 70 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/3e91c2d6-f541-48a5-a29c-726bb7317a78.png"
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"id": "620beb14-a3bc-40e8-84fc-f235b542ba61",
|
| 74 |
+
"prompt": "oil painting, impasto brush strokes, classical lighting, Rembrandt style",
|
| 75 |
+
"mode": "txt2img",
|
| 76 |
+
"seed": 7450002424425761588,
|
| 77 |
+
"width": 512,
|
| 78 |
+
"height": 768,
|
| 79 |
+
"timestamp": "2025-12-04T14:09:31.084861",
|
| 80 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/620beb14-a3bc-40e8-84fc-f235b542ba61.png"
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"id": "950520f5-b9ff-49e2-86a2-ff63ebe41e92",
|
| 84 |
+
"prompt": "ultra realistic, 35mm photography, photorealistic, cinematic lighting",
|
| 85 |
+
"mode": "txt2img",
|
| 86 |
+
"seed": 1390214708901413353,
|
| 87 |
+
"width": 512,
|
| 88 |
+
"height": 512,
|
| 89 |
+
"timestamp": "2025-12-04T13:57:18.478626",
|
| 90 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/950520f5-b9ff-49e2-86a2-ff63ebe41e92.png"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"id": "e093f3e1-0d76-4fd6-b16e-478effbcd711",
|
| 94 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 95 |
+
"mode": "txt2img",
|
| 96 |
+
"seed": 2484357327948880929,
|
| 97 |
+
"width": 768,
|
| 98 |
+
"height": 512,
|
| 99 |
+
"timestamp": "2025-12-04T13:38:22.075875",
|
| 100 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/e093f3e1-0d76-4fd6-b16e-478effbcd711.png"
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"id": "e00c8028-63d1-40a7-8504-e1a447538fe1",
|
| 104 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 105 |
+
"mode": "txt2img",
|
| 106 |
+
"seed": 6882939413923257663,
|
| 107 |
+
"width": 768,
|
| 108 |
+
"height": 512,
|
| 109 |
+
"timestamp": "2025-12-04T13:29:35.384099",
|
| 110 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/e00c8028-63d1-40a7-8504-e1a447538fe1.png"
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"id": "33f3345e-f96d-4639-ad6a-f1f29639ace4",
|
| 114 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 115 |
+
"mode": "txt2img",
|
| 116 |
+
"seed": 5403877172223779031,
|
| 117 |
+
"width": 448,
|
| 118 |
+
"height": 448,
|
| 119 |
+
"timestamp": "2025-12-04T13:27:43.827963",
|
| 120 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/33f3345e-f96d-4639-ad6a-f1f29639ace4.png"
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"id": "b13132cf-6915-47d2-b86c-9a7fe59cd11d",
|
| 124 |
+
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
| 125 |
+
"mode": "txt2img",
|
| 126 |
+
"seed": 6475212377733185643,
|
| 127 |
+
"width": 768,
|
| 128 |
+
"height": 512,
|
| 129 |
+
"timestamp": "2025-12-04T13:27:30.835543",
|
| 130 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/b13132cf-6915-47d2-b86c-9a7fe59cd11d.png"
|
| 131 |
+
},
|
| 132 |
+
{
|
| 133 |
+
"id": "139c06d9-13ce-4a83-8771-507a02278524",
|
| 134 |
+
"prompt": "high quality anime, clean lines, vibrant colors, soft rim lighting, studio lighting",
|
| 135 |
+
"mode": "txt2img",
|
| 136 |
+
"seed": 7658870821531991741,
|
| 137 |
+
"width": 448,
|
| 138 |
+
"height": 448,
|
| 139 |
+
"timestamp": "2025-12-04T13:24:58.460595",
|
| 140 |
+
"thumbnail": "/home/sanskar-modi/current_working_personal_projects/stable-diffusion-image-generator/src/assets/history/thumbnails/139c06d9-13ce-4a83-8771-507a02278524.png"
|
| 141 |
+
},
|
| 142 |
{
|
| 143 |
"id": "a6861b54-0afb-4b32-bb33-cacdadd7e639",
|
| 144 |
"prompt": "dramatic cinematic lighting, moody, film grain, Kodak Portra, filmic color grading",
|
src/sdgen/config/settings.py
CHANGED
|
@@ -23,7 +23,8 @@ class AppSettings:
|
|
| 23 |
- SHARE: enable Gradio public sharing link
|
| 24 |
"""
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
enable_xformers: bool = bool(int(os.getenv("XFORMERS", "0")))
|
| 28 |
warmup: bool = bool(int(os.getenv("WARMUP", "1")))
|
| 29 |
server_port: int = int(os.getenv("PORT", "7860"))
|
|
|
|
| 23 |
- SHARE: enable Gradio public sharing link
|
| 24 |
"""
|
| 25 |
|
| 26 |
+
model_id1: str = os.getenv("MODEL_ID1", "runwayml/stable-diffusion-v1-5")
|
| 27 |
+
model_id2: str = os.getenv("MODEL_ID2", "stabilityai/stable-diffusion-turbo")
|
| 28 |
enable_xformers: bool = bool(int(os.getenv("XFORMERS", "0")))
|
| 29 |
warmup: bool = bool(int(os.getenv("WARMUP", "1")))
|
| 30 |
server_port: int = int(os.getenv("PORT", "7860"))
|
src/sdgen/main.py
CHANGED
|
@@ -36,25 +36,39 @@ def detect_device() -> str:
|
|
| 36 |
def main() -> None:
|
| 37 |
"""Start the Stable Diffusion UI and initialize inference pipelines."""
|
| 38 |
settings = AppSettings()
|
| 39 |
-
|
|
|
|
| 40 |
|
| 41 |
device = detect_device()
|
| 42 |
|
| 43 |
-
logger.info("Loading pipeline %s",
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
if device == "cuda" and settings.warmup:
|
| 52 |
-
warmup_pipeline(
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
server_name=settings.server_host,
|
| 59 |
server_port=settings.server_port,
|
| 60 |
share=settings.share,
|
|
|
|
| 36 |
def main() -> None:
|
| 37 |
"""Start the Stable Diffusion UI and initialize inference pipelines."""
|
| 38 |
settings = AppSettings()
|
| 39 |
+
model_id1 = settings.model_id1
|
| 40 |
+
model_id2 = settings.model_id2
|
| 41 |
|
| 42 |
device = detect_device()
|
| 43 |
|
| 44 |
+
logger.info("Loading pipeline %s", model_id1)
|
| 45 |
+
pipes = {
|
| 46 |
+
"SD1.5": load_pipeline(
|
| 47 |
+
model_id=model_id1,
|
| 48 |
+
device=device,
|
| 49 |
+
use_fp16=device == "cuda",
|
| 50 |
+
enable_xformers=settings.enable_xformers,
|
| 51 |
+
),
|
| 52 |
+
"Turbo": load_pipeline(
|
| 53 |
+
model_id=model_id2,
|
| 54 |
+
device=device,
|
| 55 |
+
use_fp16=device == "cuda",
|
| 56 |
+
enable_xformers=settings.enable_xformers,
|
| 57 |
+
),
|
| 58 |
+
}
|
| 59 |
if device == "cuda" and settings.warmup:
|
| 60 |
+
warmup_pipeline(pipes["SD1.5"])
|
| 61 |
+
|
| 62 |
+
img2img_pipes = {
|
| 63 |
+
"SD1.5": prepare_img2img_pipeline(pipes["SD1.5"]),
|
| 64 |
+
"Turbo": prepare_img2img_pipeline(pipes["Turbo"]),
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
demo = build_ui(pipes, img2img_pipes)
|
| 68 |
+
demo.queue(
|
| 69 |
+
concurrency_count=1,
|
| 70 |
+
max_size=8,
|
| 71 |
+
).launch(
|
| 72 |
server_name=settings.server_host,
|
| 73 |
server_port=settings.server_port,
|
| 74 |
share=settings.share,
|
src/sdgen/presets/styles.py
CHANGED
|
@@ -13,71 +13,41 @@ PRESETS: Dict[str, Dict[str, Any]] = {
|
|
| 13 |
"Realistic Photo": {
|
| 14 |
"prompt": (
|
| 15 |
"ultra realistic, 35mm photography, \
|
| 16 |
-
|
| 17 |
-
"cinematic lighting"
|
| 18 |
),
|
| 19 |
"negative_prompt": "low quality, blurry, deformed, extra limbs",
|
| 20 |
-
"steps": 28,
|
| 21 |
-
"guidance_scale": 7.5,
|
| 22 |
-
"width": 512,
|
| 23 |
-
"height": 512,
|
| 24 |
-
"note": "Natural lighting, sharp details, realistic skin texture",
|
| 25 |
"tags": ["realistic", "photo"],
|
| 26 |
},
|
| 27 |
"Anime": {
|
| 28 |
"prompt": (
|
| 29 |
"high quality anime, clean lines, vibrant colors, \
|
| 30 |
-
|
| 31 |
-
"studio lighting"
|
| 32 |
),
|
| 33 |
"negative_prompt": "blurry, low detail, mutation, deformed",
|
| 34 |
-
"steps": 30,
|
| 35 |
-
"guidance_scale": 8.0,
|
| 36 |
-
"width": 512,
|
| 37 |
-
"height": 512,
|
| 38 |
-
"note": "Use for anime-style character generation",
|
| 39 |
"tags": ["anime", "stylized"],
|
| 40 |
},
|
| 41 |
"Cinematic / Moody": {
|
| 42 |
"prompt": (
|
| 43 |
"dramatic cinematic lighting, moody, film grain, \
|
| 44 |
-
|
| 45 |
-
"filmic color grading"
|
| 46 |
),
|
| 47 |
"negative_prompt": "oversaturated, low detail, flat lighting",
|
| 48 |
-
"steps": 30,
|
| 49 |
-
"guidance_scale": 7.0,
|
| 50 |
-
"width": 768,
|
| 51 |
-
"height": 512,
|
| 52 |
-
"note": "Wider aspect ratio for cinematic feel",
|
| 53 |
"tags": ["cinematic", "moody"],
|
| 54 |
},
|
| 55 |
"Oil Painting / Classic Art": {
|
| 56 |
"prompt": (
|
| 57 |
"oil painting, impasto brush strokes, classical \
|
| 58 |
-
|
| 59 |
-
"Rembrandt style"
|
| 60 |
),
|
| 61 |
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
| 62 |
-
"steps": 40,
|
| 63 |
-
"guidance_scale": 8.5,
|
| 64 |
-
"width": 512,
|
| 65 |
-
"height": 768,
|
| 66 |
-
"note": "Painterly aesthetic reminiscent of classical oil art",
|
| 67 |
"tags": ["art", "oil", "painterly"],
|
| 68 |
},
|
| 69 |
"Cyberpunk / Neon": {
|
| 70 |
"prompt": (
|
| 71 |
"cyberpunk city, neon reflections, wet streets, \
|
| 72 |
-
|
| 73 |
-
"synthwave aesthetic"
|
| 74 |
),
|
| 75 |
"negative_prompt": "low detail, daytime, blurry",
|
| 76 |
-
"steps": 30,
|
| 77 |
-
"guidance_scale": 7.5,
|
| 78 |
-
"width": 512,
|
| 79 |
-
"height": 768,
|
| 80 |
-
"note": "Vibrant neon-lit futuristic look",
|
| 81 |
"tags": ["cyberpunk", "neon"],
|
| 82 |
},
|
| 83 |
}
|
|
|
|
| 13 |
"Realistic Photo": {
|
| 14 |
"prompt": (
|
| 15 |
"ultra realistic, 35mm photography, \
|
| 16 |
+
photorealistic, cinematic lighting"
|
|
|
|
| 17 |
),
|
| 18 |
"negative_prompt": "low quality, blurry, deformed, extra limbs",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"tags": ["realistic", "photo"],
|
| 20 |
},
|
| 21 |
"Anime": {
|
| 22 |
"prompt": (
|
| 23 |
"high quality anime, clean lines, vibrant colors, \
|
| 24 |
+
soft rim lighting, studio lighting"
|
|
|
|
| 25 |
),
|
| 26 |
"negative_prompt": "blurry, low detail, mutation, deformed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
"tags": ["anime", "stylized"],
|
| 28 |
},
|
| 29 |
"Cinematic / Moody": {
|
| 30 |
"prompt": (
|
| 31 |
"dramatic cinematic lighting, moody, film grain, \
|
| 32 |
+
Kodak Portra, filmic color grading"
|
|
|
|
| 33 |
),
|
| 34 |
"negative_prompt": "oversaturated, low detail, flat lighting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
"tags": ["cinematic", "moody"],
|
| 36 |
},
|
| 37 |
"Oil Painting / Classic Art": {
|
| 38 |
"prompt": (
|
| 39 |
"oil painting, impasto brush strokes, classical \
|
| 40 |
+
lighting, Rembrandt style"
|
|
|
|
| 41 |
),
|
| 42 |
"negative_prompt": "blurry, cartoonish, digital artifacts",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
"tags": ["art", "oil", "painterly"],
|
| 44 |
},
|
| 45 |
"Cyberpunk / Neon": {
|
| 46 |
"prompt": (
|
| 47 |
"cyberpunk city, neon reflections, wet streets, \
|
| 48 |
+
high detail, synthwave aesthetic"
|
|
|
|
| 49 |
),
|
| 50 |
"negative_prompt": "low detail, daytime, blurry",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
"tags": ["cyberpunk", "neon"],
|
| 52 |
},
|
| 53 |
}
|
src/sdgen/sd/img2img.py
CHANGED
|
@@ -110,7 +110,7 @@ def generate_img2img(
|
|
| 110 |
with torch.autocast(device_type=autocast_device):
|
| 111 |
out = pipe(
|
| 112 |
prompt=cfg.prompt,
|
| 113 |
-
negative_prompt=cfg.
|
| 114 |
image=init,
|
| 115 |
strength=float(cfg.strength),
|
| 116 |
num_inference_steps=int(cfg.steps),
|
|
@@ -124,7 +124,7 @@ def generate_img2img(
|
|
| 124 |
meta = GenerationMetadata(
|
| 125 |
mode="img2img",
|
| 126 |
prompt=cfg.prompt,
|
| 127 |
-
negative_prompt=cfg.
|
| 128 |
steps=int(cfg.steps),
|
| 129 |
guidance_scale=float(cfg.guidance_scale),
|
| 130 |
width=width,
|
|
|
|
| 110 |
with torch.autocast(device_type=autocast_device):
|
| 111 |
out = pipe(
|
| 112 |
prompt=cfg.prompt,
|
| 113 |
+
negative_prompt=cfg.negative_prompt or None,
|
| 114 |
image=init,
|
| 115 |
strength=float(cfg.strength),
|
| 116 |
num_inference_steps=int(cfg.steps),
|
|
|
|
| 124 |
meta = GenerationMetadata(
|
| 125 |
mode="img2img",
|
| 126 |
prompt=cfg.prompt,
|
| 127 |
+
negative_prompt=cfg.negative_prompt or "",
|
| 128 |
steps=int(cfg.steps),
|
| 129 |
guidance_scale=float(cfg.guidance_scale),
|
| 130 |
width=width,
|
src/sdgen/sd/pipeline.py
CHANGED
|
@@ -6,7 +6,11 @@ import os
|
|
| 6 |
from typing import Optional
|
| 7 |
|
| 8 |
import torch
|
| 9 |
-
from diffusers import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
from sdgen.utils.logger import get_logger
|
| 12 |
|
|
@@ -29,7 +33,7 @@ def load_pipeline(
|
|
| 29 |
use_fp16: bool = True,
|
| 30 |
enable_xformers: bool = False,
|
| 31 |
torch_dtype: Optional[torch.dtype] = None,
|
| 32 |
-
scheduler:
|
| 33 |
) -> StableDiffusionPipeline:
|
| 34 |
"""Load the Stable Diffusion pipeline with optional scheduler and xFormers.
|
| 35 |
|
|
@@ -49,10 +53,16 @@ def load_pipeline(
|
|
| 49 |
|
| 50 |
if scheduler is None:
|
| 51 |
try:
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
except Exception:
|
| 57 |
scheduler = None
|
| 58 |
|
|
|
|
| 6 |
from typing import Optional
|
| 7 |
|
| 8 |
import torch
|
| 9 |
+
from diffusers import (
|
| 10 |
+
DPMSolverMultistepScheduler,
|
| 11 |
+
EulerAncestralDiscreteScheduler,
|
| 12 |
+
StableDiffusionPipeline,
|
| 13 |
+
)
|
| 14 |
|
| 15 |
from sdgen.utils.logger import get_logger
|
| 16 |
|
|
|
|
| 33 |
use_fp16: bool = True,
|
| 34 |
enable_xformers: bool = False,
|
| 35 |
torch_dtype: Optional[torch.dtype] = None,
|
| 36 |
+
scheduler: any = None,
|
| 37 |
) -> StableDiffusionPipeline:
|
| 38 |
"""Load the Stable Diffusion pipeline with optional scheduler and xFormers.
|
| 39 |
|
|
|
|
| 53 |
|
| 54 |
if scheduler is None:
|
| 55 |
try:
|
| 56 |
+
if "turbo" in model_id.lower():
|
| 57 |
+
scheduler = EulerAncestralDiscreteScheduler.from_pretrained(
|
| 58 |
+
model_id,
|
| 59 |
+
subfolder="scheduler",
|
| 60 |
+
)
|
| 61 |
+
else:
|
| 62 |
+
scheduler = DPMSolverMultistepScheduler.from_pretrained(
|
| 63 |
+
model_id,
|
| 64 |
+
subfolder="scheduler",
|
| 65 |
+
)
|
| 66 |
except Exception:
|
| 67 |
scheduler = None
|
| 68 |
|
src/sdgen/ui/layout.py
CHANGED
|
@@ -16,8 +16,6 @@ from sdgen.ui.tabs import (
|
|
| 16 |
build_txt2img_tab,
|
| 17 |
build_upscaler_tab,
|
| 18 |
)
|
| 19 |
-
from sdgen.ui.tabs.img2img_tab import Img2ImgControls
|
| 20 |
-
from sdgen.ui.tabs.txt2img_tab import Txt2ImgControls
|
| 21 |
from sdgen.upscaler.upscaler import Upscaler
|
| 22 |
from sdgen.utils.common import pretty_json, to_pil
|
| 23 |
from sdgen.utils.history import save_history_entry
|
|
@@ -42,8 +40,16 @@ def _resolve_seed(value: Any) -> int | None:
|
|
| 42 |
return None
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
def _txt2img_handler(
|
| 46 |
-
|
|
|
|
| 47 |
prompt: str,
|
| 48 |
negative: str,
|
| 49 |
steps: int,
|
|
@@ -53,6 +59,9 @@ def _txt2img_handler(
|
|
| 53 |
seed: Any,
|
| 54 |
) -> Tuple[Any, str]:
|
| 55 |
"""Run text-to-image generation."""
|
|
|
|
|
|
|
|
|
|
| 56 |
cfg = Txt2ImgConfig(
|
| 57 |
prompt=prompt or "",
|
| 58 |
negative_prompt=negative or "",
|
|
@@ -75,7 +84,8 @@ def _txt2img_handler(
|
|
| 75 |
|
| 76 |
|
| 77 |
def _img2img_handler(
|
| 78 |
-
|
|
|
|
| 79 |
input_image: Any,
|
| 80 |
prompt: str,
|
| 81 |
negative: str,
|
|
@@ -85,6 +95,9 @@ def _img2img_handler(
|
|
| 85 |
seed: Any,
|
| 86 |
) -> Tuple[Any, str]:
|
| 87 |
"""Run image-to-image generation."""
|
|
|
|
|
|
|
|
|
|
| 88 |
if input_image is None:
|
| 89 |
raise gr.Error("Upload an image to continue.")
|
| 90 |
|
|
@@ -146,7 +159,7 @@ def _upscale_handler(
|
|
| 146 |
return out_image, pretty_json(meta)
|
| 147 |
|
| 148 |
|
| 149 |
-
def build_ui(
|
| 150 |
"""Build the entire Gradio UI."""
|
| 151 |
with gr.Blocks() as demo:
|
| 152 |
gr.Markdown(
|
|
@@ -155,12 +168,29 @@ def build_ui(txt2img_pipe: Any, img2img_pipe: Any) -> gr.Blocks:
|
|
| 155 |
Diffusion toolkit."
|
| 156 |
)
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
)
|
| 161 |
|
| 162 |
-
|
| 163 |
-
handler=lambda *args:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
)
|
| 165 |
|
| 166 |
build_upscaler_tab(
|
|
@@ -174,11 +204,25 @@ def build_ui(txt2img_pipe: Any, img2img_pipe: Any) -> gr.Blocks:
|
|
| 174 |
|
| 175 |
build_history_tab()
|
| 176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
gr.Markdown(
|
| 178 |
"### Notes\n"
|
| 179 |
-
"-
|
| 180 |
-
"-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
| 182 |
)
|
| 183 |
|
| 184 |
return demo
|
|
|
|
| 16 |
build_txt2img_tab,
|
| 17 |
build_upscaler_tab,
|
| 18 |
)
|
|
|
|
|
|
|
| 19 |
from sdgen.upscaler.upscaler import Upscaler
|
| 20 |
from sdgen.utils.common import pretty_json, to_pil
|
| 21 |
from sdgen.utils.history import save_history_entry
|
|
|
|
| 40 |
return None
|
| 41 |
|
| 42 |
|
| 43 |
+
def _update_steps(model):
|
| 44 |
+
"""Upate steps based on the model."""
|
| 45 |
+
if model == "Turbo":
|
| 46 |
+
return gr.update(minimum=1, maximum=10, value=6, step=1)
|
| 47 |
+
return gr.update(minimum=10, maximum=30, value=20, step=1)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
def _txt2img_handler(
|
| 51 |
+
model_choice: str,
|
| 52 |
+
pipes: dict,
|
| 53 |
prompt: str,
|
| 54 |
negative: str,
|
| 55 |
steps: int,
|
|
|
|
| 59 |
seed: Any,
|
| 60 |
) -> Tuple[Any, str]:
|
| 61 |
"""Run text-to-image generation."""
|
| 62 |
+
model = model_choice
|
| 63 |
+
pipe = pipes[model]
|
| 64 |
+
|
| 65 |
cfg = Txt2ImgConfig(
|
| 66 |
prompt=prompt or "",
|
| 67 |
negative_prompt=negative or "",
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
def _img2img_handler(
|
| 87 |
+
model_choice: str,
|
| 88 |
+
pipes: dict,
|
| 89 |
input_image: Any,
|
| 90 |
prompt: str,
|
| 91 |
negative: str,
|
|
|
|
| 95 |
seed: Any,
|
| 96 |
) -> Tuple[Any, str]:
|
| 97 |
"""Run image-to-image generation."""
|
| 98 |
+
model = model_choice
|
| 99 |
+
pipe = pipes[model]
|
| 100 |
+
|
| 101 |
if input_image is None:
|
| 102 |
raise gr.Error("Upload an image to continue.")
|
| 103 |
|
|
|
|
| 159 |
return out_image, pretty_json(meta)
|
| 160 |
|
| 161 |
|
| 162 |
+
def build_ui(txt2img_pipes: dict, img2img_pipes: dict) -> gr.Blocks:
|
| 163 |
"""Build the entire Gradio UI."""
|
| 164 |
with gr.Blocks() as demo:
|
| 165 |
gr.Markdown(
|
|
|
|
| 168 |
Diffusion toolkit."
|
| 169 |
)
|
| 170 |
|
| 171 |
+
model_choice = gr.Dropdown(
|
| 172 |
+
choices=[
|
| 173 |
+
"SD1.5",
|
| 174 |
+
"Turbo",
|
| 175 |
+
],
|
| 176 |
+
value="SD1.5",
|
| 177 |
+
label="Model",
|
| 178 |
)
|
| 179 |
|
| 180 |
+
txt_controls = build_txt2img_tab(
|
| 181 |
+
handler=lambda model_name, *args: _txt2img_handler(
|
| 182 |
+
model_name,
|
| 183 |
+
txt2img_pipes,
|
| 184 |
+
*args,
|
| 185 |
+
),
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
img_controls = build_img2img_tab(
|
| 189 |
+
handler=lambda model_name, *args: _img2img_handler(
|
| 190 |
+
model_name,
|
| 191 |
+
img2img_pipes,
|
| 192 |
+
*args,
|
| 193 |
+
),
|
| 194 |
)
|
| 195 |
|
| 196 |
build_upscaler_tab(
|
|
|
|
| 204 |
|
| 205 |
build_history_tab()
|
| 206 |
|
| 207 |
+
model_choice.change(
|
| 208 |
+
fn=_update_steps,
|
| 209 |
+
inputs=[model_choice],
|
| 210 |
+
outputs=[txt_controls.steps],
|
| 211 |
+
)
|
| 212 |
+
model_choice.change(
|
| 213 |
+
fn=_update_steps,
|
| 214 |
+
inputs=[model_choice],
|
| 215 |
+
outputs=[img_controls.steps],
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
gr.Markdown(
|
| 219 |
"### Notes\n"
|
| 220 |
+
"- Use **History → Refresh** if new entries do not appear.\n"
|
| 221 |
+
"- Presets apply to both **Text → Image** and \
|
| 222 |
+
**Image → Image** tabs.\n"
|
| 223 |
+
"- Inference speed will be much faster on GPU \
|
| 224 |
+
(This app is hosted on CPU based HF Spaces).\n"
|
| 225 |
+
"- Use Turbo model if you prefer speed over performance."
|
| 226 |
)
|
| 227 |
|
| 228 |
return demo
|
src/sdgen/ui/tabs/history_tab.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Any, Dict, List, Optional, Tuple
|
|
| 7 |
import gradio as gr
|
| 8 |
from PIL import Image
|
| 9 |
|
| 10 |
-
from sdgen.utils.common import
|
| 11 |
from sdgen.utils.history import (
|
| 12 |
delete_history_entry,
|
| 13 |
list_history,
|
|
@@ -64,8 +64,7 @@ def load_from_dropdown(selected_label: str, entries: List[Dict[str, Any]]):
|
|
| 64 |
thumb_path = data.get("thumbnail")
|
| 65 |
img = Image.open(thumb_path) if thumb_path else None
|
| 66 |
|
| 67 |
-
|
| 68 |
-
return img, pretty_json(data)
|
| 69 |
|
| 70 |
|
| 71 |
def refresh_history():
|
|
@@ -79,7 +78,7 @@ def refresh_history():
|
|
| 79 |
else:
|
| 80 |
dd = gr.update(choices=[], value=None)
|
| 81 |
|
| 82 |
-
return dd, entries, None,
|
| 83 |
|
| 84 |
|
| 85 |
def delete_entry(selected_label: str, entries: List[Dict[str, Any]]):
|
|
@@ -102,7 +101,7 @@ def delete_entry(selected_label: str, entries: List[Dict[str, Any]]):
|
|
| 102 |
else:
|
| 103 |
dd = gr.update(choices=[], value=None)
|
| 104 |
|
| 105 |
-
return None,
|
| 106 |
|
| 107 |
|
| 108 |
# UI
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
from PIL import Image
|
| 9 |
|
| 10 |
+
from sdgen.utils.common import short_prompt
|
| 11 |
from sdgen.utils.history import (
|
| 12 |
delete_history_entry,
|
| 13 |
list_history,
|
|
|
|
| 64 |
thumb_path = data.get("thumbnail")
|
| 65 |
img = Image.open(thumb_path) if thumb_path else None
|
| 66 |
|
| 67 |
+
return img, data
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
def refresh_history():
|
|
|
|
| 78 |
else:
|
| 79 |
dd = gr.update(choices=[], value=None)
|
| 80 |
|
| 81 |
+
return dd, entries, None, {}
|
| 82 |
|
| 83 |
|
| 84 |
def delete_entry(selected_label: str, entries: List[Dict[str, Any]]):
|
|
|
|
| 101 |
else:
|
| 102 |
dd = gr.update(choices=[], value=None)
|
| 103 |
|
| 104 |
+
return None, {}, dd, new_entries
|
| 105 |
|
| 106 |
|
| 107 |
# UI
|
src/sdgen/ui/tabs/img2img_tab.py
CHANGED
|
@@ -65,12 +65,14 @@ def build_img2img_tab(handler: Callable[..., Tuple[Any, dict]]) -> Img2ImgContro
|
|
| 65 |
|
| 66 |
steps = gr.Slider(
|
| 67 |
minimum=10,
|
| 68 |
-
maximum=
|
| 69 |
-
value=
|
| 70 |
step=1,
|
| 71 |
label="Steps",
|
| 72 |
)
|
| 73 |
-
|
|
|
|
|
|
|
| 74 |
guidance = gr.Slider(
|
| 75 |
minimum=1,
|
| 76 |
maximum=15,
|
|
@@ -78,6 +80,10 @@ def build_img2img_tab(handler: Callable[..., Tuple[Any, dict]]) -> Img2ImgContro
|
|
| 78 |
step=0.5,
|
| 79 |
label="Guidance Scale",
|
| 80 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
seed = gr.Textbox(
|
| 83 |
label="Seed",
|
|
|
|
| 65 |
|
| 66 |
steps = gr.Slider(
|
| 67 |
minimum=10,
|
| 68 |
+
maximum=30,
|
| 69 |
+
value=20,
|
| 70 |
step=1,
|
| 71 |
label="Steps",
|
| 72 |
)
|
| 73 |
+
gr.Markdown(
|
| 74 |
+
"More steps → finer detail, slower runtime.",
|
| 75 |
+
)
|
| 76 |
guidance = gr.Slider(
|
| 77 |
minimum=1,
|
| 78 |
maximum=15,
|
|
|
|
| 80 |
step=0.5,
|
| 81 |
label="Guidance Scale",
|
| 82 |
)
|
| 83 |
+
gr.Markdown(
|
| 84 |
+
"Higher values make generation match \
|
| 85 |
+
the prompt more strictly. "
|
| 86 |
+
)
|
| 87 |
|
| 88 |
seed = gr.Textbox(
|
| 89 |
label="Seed",
|
src/sdgen/ui/tabs/presets_tab.py
CHANGED
|
@@ -34,17 +34,6 @@ def apply_preset(preset_name: Any) -> Tuple[Any, ...]:
|
|
| 34 |
prompt = preset.get("prompt", "")
|
| 35 |
negative = preset.get("negative_prompt", "")
|
| 36 |
|
| 37 |
-
steps = int(preset.get("steps", 30))
|
| 38 |
-
guidance = float(preset.get("guidance_scale", 7.5))
|
| 39 |
-
width = int(preset.get("width", 512))
|
| 40 |
-
height = int(preset.get("height", 512))
|
| 41 |
-
|
| 42 |
-
# For Img2Img:
|
| 43 |
-
img_steps = max(10, steps)
|
| 44 |
-
img_guidance = guidance
|
| 45 |
-
img_strength = 0.6 # neutral default
|
| 46 |
-
img_seed = ""
|
| 47 |
-
|
| 48 |
# only return data; UI wiring chooses what to set
|
| 49 |
status_msg = f"Applied preset: {preset_name}"
|
| 50 |
|
|
@@ -52,17 +41,9 @@ def apply_preset(preset_name: Any) -> Tuple[Any, ...]:
|
|
| 52 |
# txt2img
|
| 53 |
prompt,
|
| 54 |
negative,
|
| 55 |
-
steps,
|
| 56 |
-
guidance,
|
| 57 |
-
width,
|
| 58 |
-
height,
|
| 59 |
# img2img
|
| 60 |
prompt,
|
| 61 |
negative,
|
| 62 |
-
img_steps,
|
| 63 |
-
img_guidance,
|
| 64 |
-
img_strength,
|
| 65 |
-
img_seed,
|
| 66 |
# status
|
| 67 |
status_msg,
|
| 68 |
)
|
|
@@ -102,17 +83,9 @@ def build_presets_tab(
|
|
| 102 |
# txt2img
|
| 103 |
txt_controls.prompt,
|
| 104 |
txt_controls.negative,
|
| 105 |
-
txt_controls.steps,
|
| 106 |
-
txt_controls.guidance,
|
| 107 |
-
txt_controls.width,
|
| 108 |
-
txt_controls.height,
|
| 109 |
# img2img
|
| 110 |
img_controls.prompt,
|
| 111 |
img_controls.negative,
|
| 112 |
-
img_controls.steps,
|
| 113 |
-
img_controls.guidance,
|
| 114 |
-
img_controls.strength,
|
| 115 |
-
img_controls.seed,
|
| 116 |
# status markdown
|
| 117 |
status_box,
|
| 118 |
],
|
|
|
|
| 34 |
prompt = preset.get("prompt", "")
|
| 35 |
negative = preset.get("negative_prompt", "")
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# only return data; UI wiring chooses what to set
|
| 38 |
status_msg = f"Applied preset: {preset_name}"
|
| 39 |
|
|
|
|
| 41 |
# txt2img
|
| 42 |
prompt,
|
| 43 |
negative,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
# img2img
|
| 45 |
prompt,
|
| 46 |
negative,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# status
|
| 48 |
status_msg,
|
| 49 |
)
|
|
|
|
| 83 |
# txt2img
|
| 84 |
txt_controls.prompt,
|
| 85 |
txt_controls.negative,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# img2img
|
| 87 |
img_controls.prompt,
|
| 88 |
img_controls.negative,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
# status markdown
|
| 90 |
status_box,
|
| 91 |
],
|
src/sdgen/ui/tabs/txt2img_tab.py
CHANGED
|
@@ -47,13 +47,13 @@ def build_txt2img_tab(handler: Callable[..., Tuple]) -> Txt2ImgControls:
|
|
| 47 |
|
| 48 |
steps = gr.Slider(
|
| 49 |
minimum=10,
|
| 50 |
-
maximum=
|
| 51 |
-
value=
|
| 52 |
step=1,
|
| 53 |
label="Steps",
|
| 54 |
)
|
| 55 |
gr.Markdown(
|
| 56 |
-
"More steps → finer detail, slower runtime.
|
| 57 |
)
|
| 58 |
|
| 59 |
guidance = gr.Slider(
|
|
@@ -64,8 +64,8 @@ def build_txt2img_tab(handler: Callable[..., Tuple]) -> Txt2ImgControls:
|
|
| 64 |
label="Guidance Scale (CFG)",
|
| 65 |
)
|
| 66 |
gr.Markdown(
|
| 67 |
-
"Higher values make generation match
|
| 68 |
-
|
| 69 |
)
|
| 70 |
|
| 71 |
width = gr.Slider(
|
|
|
|
| 47 |
|
| 48 |
steps = gr.Slider(
|
| 49 |
minimum=10,
|
| 50 |
+
maximum=30,
|
| 51 |
+
value=20,
|
| 52 |
step=1,
|
| 53 |
label="Steps",
|
| 54 |
)
|
| 55 |
gr.Markdown(
|
| 56 |
+
"More steps → finer detail, slower runtime.",
|
| 57 |
)
|
| 58 |
|
| 59 |
guidance = gr.Slider(
|
|
|
|
| 64 |
label="Guidance Scale (CFG)",
|
| 65 |
)
|
| 66 |
gr.Markdown(
|
| 67 |
+
"Higher values make generation match \
|
| 68 |
+
the prompt more strictly. "
|
| 69 |
)
|
| 70 |
|
| 71 |
width = gr.Slider(
|