Spaces:
Running
Running
Andre
commited on
Commit
·
9c5e626
1
Parent(s):
20f0e24
added multi scene interface
Browse files- .DS_Store +0 -0
- adventurers_data.json +18 -18
- adventurers_data2.json +104 -86
- app copy.py +61 -0
- app.py +71 -6
- app_modal copy.py +93 -0
- app_modal.py +73 -9
- src/__pycache__/img_gen.cpython-311.pyc +0 -0
- src/__pycache__/prompt_gen.cpython-311.pyc +0 -0
- src/img_gen.py +1 -1
- src/prompt_gen copy 3.py +46 -0
- src/prompt_gen copy 4.py +46 -0
- src/prompt_gen.py +60 -6
- src/temp.py +3 -1
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
adventurers_data.json
CHANGED
@@ -2,30 +2,30 @@
|
|
2 |
"data": {
|
3 |
"adventurers": [
|
4 |
{
|
5 |
-
"owner": "
|
6 |
-
"id":
|
7 |
-
"name": "Blobert #
|
8 |
-
"strength":
|
9 |
-
"vitality":
|
10 |
-
"dexterity":
|
11 |
-
"intelligence":
|
12 |
-
"wisdom":
|
13 |
-
"charisma":
|
14 |
-
"level":
|
15 |
-
"xp":
|
16 |
"health": 0,
|
17 |
"beastHealth": 74,
|
18 |
-
"head":
|
19 |
-
"hand":
|
20 |
-
"chest": "
|
21 |
-
"waist": "
|
22 |
-
"foot": "
|
23 |
-
"weapon": "
|
24 |
"gold": 0,
|
25 |
"neck": null,
|
26 |
"ring": null,
|
27 |
"luck": 2,
|
28 |
-
"battleActionCount":
|
29 |
"customRenderer": null,
|
30 |
"statUpgrades": 0
|
31 |
}
|
|
|
2 |
"data": {
|
3 |
"adventurers": [
|
4 |
{
|
5 |
+
"owner": "0x29a092d0810ef4ad66075753c453d29e7ee3c714bf81fbb8130ffe0412fdd96",
|
6 |
+
"id": 225,
|
7 |
+
"name": "Blobert #446",
|
8 |
+
"strength": 2,
|
9 |
+
"vitality": 3,
|
10 |
+
"dexterity": 1,
|
11 |
+
"intelligence": 1,
|
12 |
+
"wisdom": 2,
|
13 |
+
"charisma": 3,
|
14 |
+
"level": 4,
|
15 |
+
"xp": 16,
|
16 |
"health": 0,
|
17 |
"beastHealth": 74,
|
18 |
+
"head": null,
|
19 |
+
"hand": null,
|
20 |
+
"chest": "Leather Armor",
|
21 |
+
"waist": "Leather Belt",
|
22 |
+
"foot": "Leather Boots",
|
23 |
+
"weapon": "Warhammer",
|
24 |
"gold": 0,
|
25 |
"neck": null,
|
26 |
"ring": null,
|
27 |
"luck": 2,
|
28 |
+
"battleActionCount": 3,
|
29 |
"customRenderer": null,
|
30 |
"statUpgrades": 0
|
31 |
}
|
adventurers_data2.json
CHANGED
@@ -2,66 +2,66 @@
|
|
2 |
"data": {
|
3 |
"battles": [
|
4 |
{
|
5 |
-
"adventurerId":
|
6 |
-
"adventurerHealth":
|
7 |
-
"beast": "
|
8 |
-
"beastHealth":
|
9 |
-
"beastLevel":
|
10 |
-
"seed": "
|
11 |
"attacker": "Beast",
|
12 |
"fled": false,
|
13 |
"damageDealt": 0,
|
14 |
"criticalHit": false,
|
15 |
-
"damageTaken":
|
16 |
-
"damageLocation": "
|
17 |
"xpEarnedAdventurer": 0,
|
18 |
"xpEarnedItems": 0,
|
19 |
"goldEarned": 0,
|
20 |
-
"discoveryTime": "2024-09-
|
21 |
},
|
22 |
{
|
23 |
-
"adventurerId":
|
24 |
-
"adventurerHealth":
|
25 |
-
"beast": "
|
26 |
-
"beastHealth":
|
27 |
-
"beastLevel":
|
28 |
-
"seed": "
|
29 |
"attacker": "Adventurer",
|
30 |
"fled": false,
|
31 |
-
"damageDealt":
|
32 |
"criticalHit": false,
|
33 |
"damageTaken": 0,
|
34 |
"damageLocation": null,
|
35 |
-
"xpEarnedAdventurer":
|
36 |
-
"xpEarnedItems":
|
37 |
"goldEarned": 0,
|
38 |
-
"discoveryTime": "2024-09-
|
39 |
},
|
40 |
{
|
41 |
-
"adventurerId":
|
42 |
-
"adventurerHealth":
|
43 |
-
"beast": "
|
44 |
-
"beastHealth":
|
45 |
-
"beastLevel":
|
46 |
-
"seed": "
|
47 |
-
"attacker": "
|
48 |
-
"fled":
|
49 |
"damageDealt": 0,
|
50 |
"criticalHit": false,
|
51 |
-
"damageTaken":
|
52 |
-
"damageLocation":
|
53 |
"xpEarnedAdventurer": 0,
|
54 |
"xpEarnedItems": 0,
|
55 |
"goldEarned": 0,
|
56 |
-
"discoveryTime": "2024-09-
|
57 |
},
|
58 |
{
|
59 |
-
"adventurerId":
|
60 |
-
"adventurerHealth":
|
61 |
-
"beast": "
|
62 |
-
"beastHealth":
|
63 |
-
"beastLevel":
|
64 |
-
"seed": "
|
65 |
"attacker": "Adventurer",
|
66 |
"fled": false,
|
67 |
"damageDealt": 0,
|
@@ -71,35 +71,35 @@
|
|
71 |
"xpEarnedAdventurer": 0,
|
72 |
"xpEarnedItems": 0,
|
73 |
"goldEarned": 0,
|
74 |
-
"discoveryTime": "2024-09-
|
75 |
},
|
76 |
{
|
77 |
-
"adventurerId":
|
78 |
-
"adventurerHealth":
|
79 |
-
"beast": "
|
80 |
-
"beastHealth":
|
81 |
-
"beastLevel":
|
82 |
-
"seed": "
|
83 |
-
"attacker": "
|
84 |
"fled": false,
|
85 |
"damageDealt": 0,
|
86 |
-
"criticalHit":
|
87 |
-
"damageTaken":
|
88 |
-
"damageLocation":
|
89 |
"xpEarnedAdventurer": 0,
|
90 |
"xpEarnedItems": 0,
|
91 |
"goldEarned": 0,
|
92 |
-
"discoveryTime": "2024-09-
|
93 |
},
|
94 |
{
|
95 |
-
"adventurerId":
|
96 |
-
"adventurerHealth":
|
97 |
-
"beast": "
|
98 |
-
"beastHealth":
|
99 |
-
"beastLevel":
|
100 |
-
"seed": "
|
101 |
"attacker": "Adventurer",
|
102 |
-
"fled":
|
103 |
"damageDealt": 0,
|
104 |
"criticalHit": false,
|
105 |
"damageTaken": 0,
|
@@ -107,61 +107,79 @@
|
|
107 |
"xpEarnedAdventurer": 0,
|
108 |
"xpEarnedItems": 0,
|
109 |
"goldEarned": 0,
|
110 |
-
"discoveryTime": "2024-09-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
},
|
112 |
{
|
113 |
-
"adventurerId":
|
114 |
-
"adventurerHealth":
|
115 |
-
"beast": "
|
116 |
-
"beastHealth":
|
117 |
-
"beastLevel":
|
118 |
-
"seed": "
|
119 |
"attacker": "Beast",
|
120 |
"fled": false,
|
121 |
"damageDealt": 0,
|
122 |
"criticalHit": false,
|
123 |
-
"damageTaken":
|
124 |
-
"damageLocation": "
|
125 |
"xpEarnedAdventurer": 0,
|
126 |
"xpEarnedItems": 0,
|
127 |
"goldEarned": 0,
|
128 |
-
"discoveryTime": "2024-09-
|
129 |
},
|
130 |
{
|
131 |
-
"adventurerId":
|
132 |
-
"adventurerHealth":
|
133 |
-
"beast": "
|
134 |
-
"beastHealth":
|
135 |
-
"beastLevel":
|
136 |
-
"seed": "
|
137 |
-
"attacker": "
|
138 |
-
"fled":
|
139 |
"damageDealt": 0,
|
140 |
-
"criticalHit":
|
141 |
-
"damageTaken":
|
142 |
-
"damageLocation":
|
143 |
"xpEarnedAdventurer": 0,
|
144 |
"xpEarnedItems": 0,
|
145 |
"goldEarned": 0,
|
146 |
-
"discoveryTime": "2024-09-
|
147 |
},
|
148 |
{
|
149 |
-
"adventurerId":
|
150 |
-
"adventurerHealth":
|
151 |
-
"beast": "
|
152 |
"beastHealth": 74,
|
153 |
-
"beastLevel":
|
154 |
-
"seed": "
|
155 |
"attacker": "Beast",
|
156 |
"fled": false,
|
157 |
"damageDealt": 0,
|
158 |
-
"criticalHit":
|
159 |
-
"damageTaken":
|
160 |
-
"damageLocation": "
|
161 |
"xpEarnedAdventurer": 0,
|
162 |
"xpEarnedItems": 0,
|
163 |
"goldEarned": 0,
|
164 |
-
"discoveryTime": "2024-09-
|
165 |
}
|
166 |
]
|
167 |
}
|
|
|
2 |
"data": {
|
3 |
"battles": [
|
4 |
{
|
5 |
+
"adventurerId": 225,
|
6 |
+
"adventurerHealth": 24,
|
7 |
+
"beast": "Dragon",
|
8 |
+
"beastHealth": 74,
|
9 |
+
"beastLevel": 5,
|
10 |
+
"seed": "0x141120e5",
|
11 |
"attacker": "Beast",
|
12 |
"fled": false,
|
13 |
"damageDealt": 0,
|
14 |
"criticalHit": false,
|
15 |
+
"damageTaken": 24,
|
16 |
+
"damageLocation": "Foot",
|
17 |
"xpEarnedAdventurer": 0,
|
18 |
"xpEarnedItems": 0,
|
19 |
"goldEarned": 0,
|
20 |
+
"discoveryTime": "2024-09-14T10:53:37.040Z"
|
21 |
},
|
22 |
{
|
23 |
+
"adventurerId": 225,
|
24 |
+
"adventurerHealth": 0,
|
25 |
+
"beast": "Dragon",
|
26 |
+
"beastHealth": 74,
|
27 |
+
"beastLevel": 5,
|
28 |
+
"seed": "0x141120e5",
|
29 |
"attacker": "Adventurer",
|
30 |
"fled": false,
|
31 |
+
"damageDealt": 0,
|
32 |
"criticalHit": false,
|
33 |
"damageTaken": 0,
|
34 |
"damageLocation": null,
|
35 |
+
"xpEarnedAdventurer": 0,
|
36 |
+
"xpEarnedItems": 0,
|
37 |
"goldEarned": 0,
|
38 |
+
"discoveryTime": "2024-09-14T10:53:37.040Z"
|
39 |
},
|
40 |
{
|
41 |
+
"adventurerId": 225,
|
42 |
+
"adventurerHealth": 72,
|
43 |
+
"beast": "Dragon",
|
44 |
+
"beastHealth": 74,
|
45 |
+
"beastLevel": 5,
|
46 |
+
"seed": "0x141120e5",
|
47 |
+
"attacker": "Beast",
|
48 |
+
"fled": false,
|
49 |
"damageDealt": 0,
|
50 |
"criticalHit": false,
|
51 |
+
"damageTaken": 24,
|
52 |
+
"damageLocation": "Chest",
|
53 |
"xpEarnedAdventurer": 0,
|
54 |
"xpEarnedItems": 0,
|
55 |
"goldEarned": 0,
|
56 |
+
"discoveryTime": "2024-09-14T10:53:06.844Z"
|
57 |
},
|
58 |
{
|
59 |
+
"adventurerId": 225,
|
60 |
+
"adventurerHealth": 24,
|
61 |
+
"beast": "Dragon",
|
62 |
+
"beastHealth": 74,
|
63 |
+
"beastLevel": 5,
|
64 |
+
"seed": "0x141120e5",
|
65 |
"attacker": "Adventurer",
|
66 |
"fled": false,
|
67 |
"damageDealt": 0,
|
|
|
71 |
"xpEarnedAdventurer": 0,
|
72 |
"xpEarnedItems": 0,
|
73 |
"goldEarned": 0,
|
74 |
+
"discoveryTime": "2024-09-14T10:53:37.039Z"
|
75 |
},
|
76 |
{
|
77 |
+
"adventurerId": 225,
|
78 |
+
"adventurerHealth": 48,
|
79 |
+
"beast": "Dragon",
|
80 |
+
"beastHealth": 74,
|
81 |
+
"beastLevel": 5,
|
82 |
+
"seed": "0x141120e5",
|
83 |
+
"attacker": "Adventurer",
|
84 |
"fled": false,
|
85 |
"damageDealt": 0,
|
86 |
+
"criticalHit": false,
|
87 |
+
"damageTaken": 0,
|
88 |
+
"damageLocation": null,
|
89 |
"xpEarnedAdventurer": 0,
|
90 |
"xpEarnedItems": 0,
|
91 |
"goldEarned": 0,
|
92 |
+
"discoveryTime": "2024-09-14T10:53:37.039Z"
|
93 |
},
|
94 |
{
|
95 |
+
"adventurerId": 225,
|
96 |
+
"adventurerHealth": 31,
|
97 |
+
"beast": "Tarrasque",
|
98 |
+
"beastHealth": 0,
|
99 |
+
"beastLevel": 6,
|
100 |
+
"seed": "0xa09ad3ea",
|
101 |
"attacker": "Adventurer",
|
102 |
+
"fled": true,
|
103 |
"damageDealt": 0,
|
104 |
"criticalHit": false,
|
105 |
"damageTaken": 0,
|
|
|
107 |
"xpEarnedAdventurer": 0,
|
108 |
"xpEarnedItems": 0,
|
109 |
"goldEarned": 0,
|
110 |
+
"discoveryTime": "2024-09-14T10:51:36.286Z"
|
111 |
+
},
|
112 |
+
{
|
113 |
+
"adventurerId": 225,
|
114 |
+
"adventurerHealth": 90,
|
115 |
+
"beast": "Spider",
|
116 |
+
"beastHealth": 0,
|
117 |
+
"beastLevel": 1,
|
118 |
+
"seed": "0x5a60e008",
|
119 |
+
"attacker": "Adventurer",
|
120 |
+
"fled": false,
|
121 |
+
"damageDealt": 4,
|
122 |
+
"criticalHit": false,
|
123 |
+
"damageTaken": 0,
|
124 |
+
"damageLocation": null,
|
125 |
+
"xpEarnedAdventurer": 4,
|
126 |
+
"xpEarnedItems": 8,
|
127 |
+
"goldEarned": 0,
|
128 |
+
"discoveryTime": "2024-09-14T10:50:02.212Z"
|
129 |
},
|
130 |
{
|
131 |
+
"adventurerId": 225,
|
132 |
+
"adventurerHealth": 90,
|
133 |
+
"beast": "Bear",
|
134 |
+
"beastHealth": 3,
|
135 |
+
"beastLevel": 1,
|
136 |
+
"seed": "0xe1",
|
137 |
"attacker": "Beast",
|
138 |
"fled": false,
|
139 |
"damageDealt": 0,
|
140 |
"criticalHit": false,
|
141 |
+
"damageTaken": 10,
|
142 |
+
"damageLocation": "Chest",
|
143 |
"xpEarnedAdventurer": 0,
|
144 |
"xpEarnedItems": 0,
|
145 |
"goldEarned": 0,
|
146 |
+
"discoveryTime": "2024-09-10T18:35:04.955Z"
|
147 |
},
|
148 |
{
|
149 |
+
"adventurerId": 225,
|
150 |
+
"adventurerHealth": 31,
|
151 |
+
"beast": "Tarrasque",
|
152 |
+
"beastHealth": 58,
|
153 |
+
"beastLevel": 6,
|
154 |
+
"seed": "0xa09ad3ea",
|
155 |
+
"attacker": "Beast",
|
156 |
+
"fled": false,
|
157 |
"damageDealt": 0,
|
158 |
+
"criticalHit": true,
|
159 |
+
"damageTaken": 89,
|
160 |
+
"damageLocation": "Foot",
|
161 |
"xpEarnedAdventurer": 0,
|
162 |
"xpEarnedItems": 0,
|
163 |
"goldEarned": 0,
|
164 |
+
"discoveryTime": "2024-09-14T10:51:36.286Z"
|
165 |
},
|
166 |
{
|
167 |
+
"adventurerId": 225,
|
168 |
+
"adventurerHealth": 48,
|
169 |
+
"beast": "Dragon",
|
170 |
"beastHealth": 74,
|
171 |
+
"beastLevel": 5,
|
172 |
+
"seed": "0x141120e5",
|
173 |
"attacker": "Beast",
|
174 |
"fled": false,
|
175 |
"damageDealt": 0,
|
176 |
+
"criticalHit": false,
|
177 |
+
"damageTaken": 24,
|
178 |
+
"damageLocation": "Waist",
|
179 |
"xpEarnedAdventurer": 0,
|
180 |
"xpEarnedItems": 0,
|
181 |
"goldEarned": 0,
|
182 |
+
"discoveryTime": "2024-09-14T10:53:37.039Z"
|
183 |
}
|
184 |
]
|
185 |
}
|
app copy.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
# venv w python3.11
|
3 |
+
from config.config import api_token # Direct import
|
4 |
+
from config.models import models
|
5 |
+
import gradio as gr
|
6 |
+
from src.img_gen import generate_image
|
7 |
+
from metadata.metadata import fetch_metadata
|
8 |
+
|
9 |
+
# Gradio Interface
|
10 |
+
def gradio_interface():
|
11 |
+
with gr.Blocks(css="""
|
12 |
+
.gradio-container {
|
13 |
+
background-image: url('');
|
14 |
+
background-size: cover;
|
15 |
+
background-position: center;
|
16 |
+
}
|
17 |
+
.output-image img {
|
18 |
+
width: 2500px; /* Force image to fill container width */
|
19 |
+
object-fit: cover; /* ACTIVATE FOR IMAGE-FIT CONTAINER */
|
20 |
+
}
|
21 |
+
""") as demo:
|
22 |
+
gr.Markdown("# ========== Loot Survivor - AI Image Generator ==========")
|
23 |
+
with gr.Row():
|
24 |
+
# Set default values for dropdowns
|
25 |
+
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
26 |
+
adventurer_id = gr.Number(label="Adventurer ID:")
|
27 |
+
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
28 |
+
scene_dropdown = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Adventurer Portait")
|
29 |
+
#model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
|
30 |
+
with gr.Row():
|
31 |
+
# Add a text box for custom user input (max 200 characters)
|
32 |
+
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
33 |
+
with gr.Row():
|
34 |
+
generate_button = gr.Button("Generate Image")
|
35 |
+
with gr.Row():
|
36 |
+
output_image1 = gr.Image(elem_classes="output-image", label="Generated Image", show_label=False, scale=1, width="100%")
|
37 |
+
output_image2 = gr.Image(elem_classes="output-image", label="Generated Image", show_label=False, scale=1, width="100%")
|
38 |
+
output_image3 = gr.Image(elem_classes="output-image", label="Generated Image", show_label=False, scale=1, width="100%")
|
39 |
+
output_image4 = gr.Image(elem_classes="output-image", label="Generated Image", show_label=False, scale=1, width="100%")
|
40 |
+
with gr.Row():
|
41 |
+
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
42 |
+
# Connect the button to the function
|
43 |
+
generate_button.click(
|
44 |
+
generate_image,
|
45 |
+
inputs=[adventurer_id,
|
46 |
+
#prompt_dropdown,
|
47 |
+
#character_dropdown,
|
48 |
+
scene_dropdown,
|
49 |
+
#model_dropdown,
|
50 |
+
custom_prompt_input,
|
51 |
+
],
|
52 |
+
outputs=[output_image1, status_text]
|
53 |
+
)
|
54 |
+
return demo
|
55 |
+
|
56 |
+
# Create the demo instance
|
57 |
+
demo = gradio_interface()
|
58 |
+
|
59 |
+
# Only launch if running directly
|
60 |
+
if __name__ == "__main__":
|
61 |
+
demo.queue().launch()
|
app.py
CHANGED
@@ -8,6 +8,7 @@ from metadata.metadata import fetch_metadata
|
|
8 |
|
9 |
# Gradio Interface
|
10 |
def gradio_interface():
|
|
|
11 |
with gr.Blocks(css="""
|
12 |
.gradio-container {
|
13 |
background-image: url('');
|
@@ -25,15 +26,25 @@ def gradio_interface():
|
|
25 |
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
26 |
adventurer_id = gr.Number(label="Adventurer ID:")
|
27 |
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
#model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
|
30 |
-
with gr.Row():
|
31 |
# Add a text box for custom user input (max 200 characters)
|
32 |
-
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
33 |
with gr.Row():
|
34 |
generate_button = gr.Button("Generate Image")
|
35 |
with gr.Row():
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
with gr.Row():
|
38 |
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
39 |
# Connect the button to the function
|
@@ -42,12 +53,66 @@ def gradio_interface():
|
|
42 |
inputs=[adventurer_id,
|
43 |
#prompt_dropdown,
|
44 |
#character_dropdown,
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
#model_dropdown,
|
47 |
custom_prompt_input,
|
48 |
],
|
49 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
)
|
|
|
51 |
return demo
|
52 |
|
53 |
# Create the demo instance
|
|
|
8 |
|
9 |
# Gradio Interface
|
10 |
def gradio_interface():
|
11 |
+
|
12 |
with gr.Blocks(css="""
|
13 |
.gradio-container {
|
14 |
background-image: url('');
|
|
|
26 |
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
27 |
adventurer_id = gr.Number(label="Adventurer ID:")
|
28 |
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
29 |
+
scene_dropdown1 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Adventurer Portait", visible=False )
|
30 |
+
scene_dropdown2 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Beast Portait", visible=False )
|
31 |
+
scene_dropdown3 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Encounter", visible=False )
|
32 |
+
scene_dropdown4 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Last Battle", visible=False )
|
33 |
+
scene_dropdown5 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Loot Bag", visible=False )
|
34 |
+
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
35 |
#model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
|
36 |
+
#with gr.Row():
|
37 |
# Add a text box for custom user input (max 200 characters)
|
|
|
38 |
with gr.Row():
|
39 |
generate_button = gr.Button("Generate Image")
|
40 |
with gr.Row():
|
41 |
+
output_image1 = gr.Image(elem_classes="output-image", label="Adventurer Portait", show_label=True, scale=1, width="100%")
|
42 |
+
output_image2 = gr.Image(elem_classes="output-image", label="Beast Portait", show_label=True, scale=1, width="100%")
|
43 |
+
with gr.Row():
|
44 |
+
output_image3 = gr.Image(elem_classes="output-image", label="Encounter", show_label=True, scale=1, width="100%")
|
45 |
+
output_image4 = gr.Image(elem_classes="output-image", label="Last Battle", show_label=True, scale=1, width="100%")
|
46 |
+
output_image5 = gr.Image(elem_classes="output-image", label="Loot Bag", show_label=True, scale=1, width="100%")
|
47 |
+
|
48 |
with gr.Row():
|
49 |
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
50 |
# Connect the button to the function
|
|
|
53 |
inputs=[adventurer_id,
|
54 |
#prompt_dropdown,
|
55 |
#character_dropdown,
|
56 |
+
scene_dropdown1,
|
57 |
+
#model_dropdown,
|
58 |
+
custom_prompt_input,
|
59 |
+
],
|
60 |
+
outputs=[output_image1, status_text],
|
61 |
+
show_progress_on=output_image1,
|
62 |
+
)
|
63 |
+
generate_button.click(
|
64 |
+
generate_image,
|
65 |
+
inputs=[adventurer_id,
|
66 |
+
#prompt_dropdown,
|
67 |
+
#character_dropdown,
|
68 |
+
scene_dropdown2,
|
69 |
+
#model_dropdown,
|
70 |
+
custom_prompt_input,
|
71 |
+
],
|
72 |
+
outputs=[output_image2, status_text],
|
73 |
+
show_progress_on=output_image2,
|
74 |
+
|
75 |
+
)
|
76 |
+
generate_button.click(
|
77 |
+
generate_image,
|
78 |
+
inputs=[adventurer_id,
|
79 |
+
#prompt_dropdown,
|
80 |
+
#character_dropdown,
|
81 |
+
scene_dropdown3,
|
82 |
+
#model_dropdown,
|
83 |
+
custom_prompt_input,
|
84 |
+
],
|
85 |
+
outputs=[output_image3, status_text],
|
86 |
+
show_progress_on=output_image3,
|
87 |
+
|
88 |
+
)
|
89 |
+
generate_button.click(
|
90 |
+
generate_image,
|
91 |
+
inputs=[adventurer_id,
|
92 |
+
#prompt_dropdown,
|
93 |
+
#character_dropdown,
|
94 |
+
scene_dropdown4,
|
95 |
#model_dropdown,
|
96 |
custom_prompt_input,
|
97 |
],
|
98 |
+
outputs=[output_image4, status_text],
|
99 |
+
show_progress_on=output_image4,
|
100 |
+
|
101 |
+
)
|
102 |
+
generate_button.click(
|
103 |
+
generate_image,
|
104 |
+
inputs=[adventurer_id,
|
105 |
+
#prompt_dropdown,
|
106 |
+
#character_dropdown,
|
107 |
+
scene_dropdown5,
|
108 |
+
#model_dropdown,
|
109 |
+
custom_prompt_input,
|
110 |
+
],
|
111 |
+
outputs=[output_image5, status_text],
|
112 |
+
show_progress_on=output_image5,
|
113 |
+
|
114 |
)
|
115 |
+
|
116 |
return demo
|
117 |
|
118 |
# Create the demo instance
|
app_modal copy.py
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# gradio_interface.py
|
2 |
+
import gradio as gr
|
3 |
+
import modal
|
4 |
+
from config.models import models_modal # Indirect import
|
5 |
+
#from img_gen import generate_image
|
6 |
+
|
7 |
+
print("Hello from gradio_interface_head!")
|
8 |
+
|
9 |
+
# Modal remote function synchronously
|
10 |
+
def generate(adventurer_id,
|
11 |
+
#prompt_dropdown,
|
12 |
+
#character_dropdown,
|
13 |
+
scene_dropdown,
|
14 |
+
#model_dropdown,
|
15 |
+
custom_prompt_input,
|
16 |
+
cpu_gpu ="GPU",
|
17 |
+
):
|
18 |
+
# Debug:
|
19 |
+
debug_message = f"Debug: Button clicked! Inputs - ID: {adventurer_id}, Scene: {scene_dropdown}, Custom Prompt: {custom_prompt_input}"
|
20 |
+
print(debug_message) # Print to console for debugging
|
21 |
+
try:
|
22 |
+
# Check for CPU/GPU dropdown option
|
23 |
+
if cpu_gpu == "GPU":
|
24 |
+
f = modal.Function.from_name("LS-img-gen-modal", "generate_image_gpu")
|
25 |
+
else:
|
26 |
+
f = modal.Function.from_name("LS-img-gen-modal", "generate_image_cpu")
|
27 |
+
|
28 |
+
print ("Sending to external function")
|
29 |
+
# Import the remote function
|
30 |
+
image_path, message = f.remote(
|
31 |
+
adventurer_id,
|
32 |
+
#prompt_dropdown,
|
33 |
+
#character_dropdown,
|
34 |
+
scene_dropdown,
|
35 |
+
#model_dropdown,
|
36 |
+
custom_prompt_input,
|
37 |
+
)
|
38 |
+
return image_path, message
|
39 |
+
except Exception as e:
|
40 |
+
return None, f"Error calling generate_image function: {e}"
|
41 |
+
|
42 |
+
|
43 |
+
# Gradio Interface
|
44 |
+
def gradio_interface():
|
45 |
+
with gr.Blocks(css="""
|
46 |
+
.gradio-container {
|
47 |
+
background-image: url('');
|
48 |
+
background-size: cover;
|
49 |
+
background-position: center;
|
50 |
+
}
|
51 |
+
.output-image img {
|
52 |
+
width: 2500px; /* Force image to fill container width */
|
53 |
+
object-fit: cover; /* ACTIVATE FOR IMAGE-FIT CONTAINER */
|
54 |
+
}
|
55 |
+
""") as demo:
|
56 |
+
gr.Markdown("# ========== Loot Survivor - AI Image Generator ==========")
|
57 |
+
with gr.Row():
|
58 |
+
# Set default values for dropdowns
|
59 |
+
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
60 |
+
adventurer_id = gr.Number(label="Adventurer ID:")
|
61 |
+
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
62 |
+
scene_dropdown = gr.Dropdown(choices=["Adventurer Portait", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Adventurer Portait")
|
63 |
+
#model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models_modal], label="Select Model", value=models_modal[0]["alias"])
|
64 |
+
with gr.Row():
|
65 |
+
# Add a text box for custom user input (max 200 characters)
|
66 |
+
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
67 |
+
with gr.Row():
|
68 |
+
generate_button = gr.Button("Generate Image")
|
69 |
+
with gr.Row():
|
70 |
+
output_image = gr.Image(elem_classes="output-image", label="Generated Image", show_label=False, scale=1, width="100%")
|
71 |
+
with gr.Row():
|
72 |
+
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
73 |
+
|
74 |
+
# Connect the button to the function
|
75 |
+
generate_button.click(
|
76 |
+
generate,
|
77 |
+
inputs=[adventurer_id,
|
78 |
+
#prompt_dropdown,
|
79 |
+
#character_dropdown,
|
80 |
+
scene_dropdown,
|
81 |
+
#model_dropdown,
|
82 |
+
custom_prompt_input,
|
83 |
+
],
|
84 |
+
outputs=[output_image, status_text]
|
85 |
+
)
|
86 |
+
return demo
|
87 |
+
|
88 |
+
# Create the demo instance
|
89 |
+
demo = gradio_interface()
|
90 |
+
|
91 |
+
# Only launch if running directly
|
92 |
+
if __name__ == "__main__":
|
93 |
+
demo.queue().launch()
|
app_modal.py
CHANGED
@@ -42,6 +42,7 @@ def generate(adventurer_id,
|
|
42 |
|
43 |
# Gradio Interface
|
44 |
def gradio_interface():
|
|
|
45 |
with gr.Blocks(css="""
|
46 |
.gradio-container {
|
47 |
background-image: url('');
|
@@ -53,36 +54,99 @@ def gradio_interface():
|
|
53 |
object-fit: cover; /* ACTIVATE FOR IMAGE-FIT CONTAINER */
|
54 |
}
|
55 |
""") as demo:
|
56 |
-
gr.Markdown("# ========== Loot Survivor - AI Image Generator ==========")
|
57 |
with gr.Row():
|
58 |
# Set default values for dropdowns
|
59 |
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
60 |
adventurer_id = gr.Number(label="Adventurer ID:")
|
61 |
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
# Add a text box for custom user input (max 200 characters)
|
66 |
-
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
67 |
with gr.Row():
|
68 |
generate_button = gr.Button("Generate Image")
|
69 |
with gr.Row():
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
with gr.Row():
|
72 |
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
73 |
-
|
74 |
# Connect the button to the function
|
75 |
generate_button.click(
|
76 |
generate,
|
77 |
inputs=[adventurer_id,
|
78 |
#prompt_dropdown,
|
79 |
#character_dropdown,
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
#model_dropdown,
|
82 |
custom_prompt_input,
|
83 |
],
|
84 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
)
|
|
|
86 |
return demo
|
87 |
|
88 |
# Create the demo instance
|
|
|
42 |
|
43 |
# Gradio Interface
|
44 |
def gradio_interface():
|
45 |
+
|
46 |
with gr.Blocks(css="""
|
47 |
.gradio-container {
|
48 |
background-image: url('');
|
|
|
54 |
object-fit: cover; /* ACTIVATE FOR IMAGE-FIT CONTAINER */
|
55 |
}
|
56 |
""") as demo:
|
57 |
+
gr.Markdown("# ========== Loot Survivor - AI Image Generator ========== modal GPU")
|
58 |
with gr.Row():
|
59 |
# Set default values for dropdowns
|
60 |
#prompt_dropdown = gr.Dropdown(choices=[p["alias"] for p in prompts], label="Select Beast", value=prompts[0]["alias"])
|
61 |
adventurer_id = gr.Number(label="Adventurer ID:")
|
62 |
#character_dropdown = gr.Dropdown(choices=["Wizard", "Hunter", "Warrior"], label="Select Character Type", value="Wizard")
|
63 |
+
scene_dropdown1 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Adventurer Portait", visible=False )
|
64 |
+
scene_dropdown2 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Beast Portait", visible=False )
|
65 |
+
scene_dropdown3 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Encounter", visible=False )
|
66 |
+
scene_dropdown4 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Last Battle", visible=False )
|
67 |
+
scene_dropdown5 = gr.Dropdown(choices=["Adventurer Portait", "Encounter", "Beast Portait", "Last Battle", "Loot Bag"], label="Select Scene", value="Loot Bag", visible=False )
|
68 |
+
custom_prompt_input = gr.Textbox(label="Custom Prompt (Optional)", placeholder="Enter additional details (max 200 chars)...", max_lines=1, max_length=200)
|
69 |
+
#model_dropdown = gr.Dropdown(choices=[m["alias"] for m in models], label="Select Model", value=models[0]["alias"])
|
70 |
+
#with gr.Row():
|
71 |
# Add a text box for custom user input (max 200 characters)
|
|
|
72 |
with gr.Row():
|
73 |
generate_button = gr.Button("Generate Image")
|
74 |
with gr.Row():
|
75 |
+
output_image1 = gr.Image(elem_classes="output-image", label="Adventurer Portait", show_label=True, scale=1, width="100%")
|
76 |
+
output_image2 = gr.Image(elem_classes="output-image", label="Beast Portait", show_label=True, scale=1, width="100%")
|
77 |
+
with gr.Row():
|
78 |
+
output_image3 = gr.Image(elem_classes="output-image", label="Encounter", show_label=True, scale=1, width="100%")
|
79 |
+
output_image4 = gr.Image(elem_classes="output-image", label="Last Battle", show_label=True, scale=1, width="100%")
|
80 |
+
output_image5 = gr.Image(elem_classes="output-image", label="Loot Bag", show_label=True, scale=1, width="100%")
|
81 |
+
|
82 |
with gr.Row():
|
83 |
status_text = gr.Textbox(label="Status", placeholder="Waiting for input...", interactive=False)
|
|
|
84 |
# Connect the button to the function
|
85 |
generate_button.click(
|
86 |
generate,
|
87 |
inputs=[adventurer_id,
|
88 |
#prompt_dropdown,
|
89 |
#character_dropdown,
|
90 |
+
scene_dropdown1,
|
91 |
+
#model_dropdown,
|
92 |
+
custom_prompt_input,
|
93 |
+
],
|
94 |
+
outputs=[output_image1, status_text],
|
95 |
+
show_progress_on=output_image1,
|
96 |
+
)
|
97 |
+
generate_button.click(
|
98 |
+
generate,
|
99 |
+
inputs=[adventurer_id,
|
100 |
+
#prompt_dropdown,
|
101 |
+
#character_dropdown,
|
102 |
+
scene_dropdown2,
|
103 |
#model_dropdown,
|
104 |
custom_prompt_input,
|
105 |
],
|
106 |
+
outputs=[output_image2, status_text],
|
107 |
+
show_progress_on=output_image2,
|
108 |
+
|
109 |
+
)
|
110 |
+
generate_button.click(
|
111 |
+
generate,
|
112 |
+
inputs=[adventurer_id,
|
113 |
+
#prompt_dropdown,
|
114 |
+
#character_dropdown,
|
115 |
+
scene_dropdown3,
|
116 |
+
#model_dropdown,
|
117 |
+
custom_prompt_input,
|
118 |
+
],
|
119 |
+
outputs=[output_image3, status_text],
|
120 |
+
show_progress_on=output_image3,
|
121 |
+
|
122 |
+
)
|
123 |
+
generate_button.click(
|
124 |
+
generate,
|
125 |
+
inputs=[adventurer_id,
|
126 |
+
#prompt_dropdown,
|
127 |
+
#character_dropdown,
|
128 |
+
scene_dropdown4,
|
129 |
+
#model_dropdown,
|
130 |
+
custom_prompt_input,
|
131 |
+
],
|
132 |
+
outputs=[output_image4, status_text],
|
133 |
+
show_progress_on=output_image4,
|
134 |
+
|
135 |
+
)
|
136 |
+
generate_button.click(
|
137 |
+
generate,
|
138 |
+
inputs=[adventurer_id,
|
139 |
+
#prompt_dropdown,
|
140 |
+
#character_dropdown,
|
141 |
+
scene_dropdown5,
|
142 |
+
#model_dropdown,
|
143 |
+
custom_prompt_input,
|
144 |
+
],
|
145 |
+
outputs=[output_image5, status_text],
|
146 |
+
show_progress_on=output_image5,
|
147 |
+
|
148 |
)
|
149 |
+
|
150 |
return demo
|
151 |
|
152 |
# Create the demo instance
|
src/__pycache__/img_gen.cpython-311.pyc
CHANGED
Binary files a/src/__pycache__/img_gen.cpython-311.pyc and b/src/__pycache__/img_gen.cpython-311.pyc differ
|
|
src/__pycache__/prompt_gen.cpython-311.pyc
CHANGED
Binary files a/src/__pycache__/prompt_gen.cpython-311.pyc and b/src/__pycache__/prompt_gen.cpython-311.pyc differ
|
|
src/img_gen.py
CHANGED
@@ -101,7 +101,7 @@ def generate_image(
|
|
101 |
|
102 |
message = f"Image generated successfully! Call the banners! \n\n=====ADVENTURER GENERATED===== \nID: {id}\nNAME: {name}\nWEAPON: {weapon_equipment}\nHEAD: {head_equipment}\nHAND: {hand_equipment}\nCHEST: {chest_equipment}\nWAIST: {waist_equipment}\nFOOT: {foot_equipment}\nGOLD: {gold_equipment}\nLAST BATTLE BEAST: {beast_last_battle}"
|
103 |
|
104 |
-
file_name_extension = f"{id}_{beast_last_battle}"
|
105 |
|
106 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
107 |
|
|
|
101 |
|
102 |
message = f"Image generated successfully! Call the banners! \n\n=====ADVENTURER GENERATED===== \nID: {id}\nNAME: {name}\nWEAPON: {weapon_equipment}\nHEAD: {head_equipment}\nHAND: {hand_equipment}\nCHEST: {chest_equipment}\nWAIST: {waist_equipment}\nFOOT: {foot_equipment}\nGOLD: {gold_equipment}\nLAST BATTLE BEAST: {beast_last_battle}"
|
103 |
|
104 |
+
file_name_extension = f"{id}_{weapon_equipment}_{head_equipment}_{hand_equipment}_{chest_equipment}_{waist_equipment}_{foot_equipment}_{gold_equipment}_{beast_last_battle}"
|
105 |
|
106 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
107 |
|
src/prompt_gen copy 3.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from metadata.metadata import fetch_metadata
|
2 |
+
|
3 |
+
def prompt_gen(adventurer_id, scene_dropdown):
|
4 |
+
adventurer = fetch_metadata(adventurer_id)
|
5 |
+
print(f"ANDRE {adventurer['name']}")
|
6 |
+
|
7 |
+
id = adventurer['id']
|
8 |
+
name = adventurer['name']
|
9 |
+
weapon_equipment = adventurer['weapon']
|
10 |
+
head_equipment = adventurer['head']
|
11 |
+
hand_equipment = adventurer['hand']
|
12 |
+
chest_equipment = adventurer['chest']
|
13 |
+
waist_equipment = adventurer['waist']
|
14 |
+
foot_equipment = adventurer['foot']
|
15 |
+
gold_equipment = adventurer['gold']
|
16 |
+
beast_last_battle = adventurer['beast']
|
17 |
+
|
18 |
+
# Check for weapon = None to fix eventual generator mistakes
|
19 |
+
if weapon_equipment == None:
|
20 |
+
weapon_sentence = "holding nothing in his hands"
|
21 |
+
else:
|
22 |
+
weapon_sentence = f"holding only a {weapon_equipment}"
|
23 |
+
|
24 |
+
# if character_dropdown == "Wizard":
|
25 |
+
# character_attack_sentence = f"The adventurer is attacking using powerful magic"
|
26 |
+
# else:
|
27 |
+
# character_attack_sentence = f"The adventurer is attacking using his {weapon_equipment}"
|
28 |
+
|
29 |
+
|
30 |
+
# Set the custom prompt variables
|
31 |
+
if scene_dropdown == "Adventurer Portait":
|
32 |
+
prompt = f"A portait of a medieval, fantasy adventurer, {weapon_sentence} (depending on his weapon, make the character dressed as a warrior, or as a hunter or as a wizard). He is also equiped in the head with a {head_equipment}, the hands with {hand_equipment}, the chest with a {chest_equipment}, and the waist with a {waist_equipment}. Please be sure to use only medieval items that were possble to be made in that period. Make the adventurer unshaved and dirty, he have been figthing for days down into the dungeons. Low light environment. Unreal Engine render style, photorealistic, atmospheric dark light, realistic fantasy style."
|
33 |
+
|
34 |
+
if scene_dropdown == "Beast Portait":
|
35 |
+
prompt = f"A massive {beast_last_battle} stands in its natural domain—a place that reflects its primal essence. The beast's eyes burn with an eerie, intelligent light, and its powerful limbs are poised for action, as if ready to pounce or defend its territory. It roars menacingly surrounded by broken weapons and bones of his past preys. Torchlit environment, underground dungeons, or dense forests, or jagged mountains, or dark caves, or misty damp swamps. Unreal Engine render style, photorealistic, atmospheric dark lights, realistic fantasy style."
|
36 |
+
|
37 |
+
if scene_dropdown == "Last Battle":
|
38 |
+
prompt = f"A battle between a medieval fantasy adventurer, and a massive {beast_last_battle}. The adventurer is {weapon_sentence}. He is also equiped in the head with {head_equipment}, the hands with {hand_equipment}, the chest with {chest_equipment}, the waist with {waist_equipment}, the feet with {foot_equipment}. Use only medieval items that were possible to be made in that period. The {beast_last_battle} stands in its natural domain—a place that reflects its primal essence. The beast's eyes burn with an eerie, intelligent light, and its powerful limbs are poised for action, as if ready to pounce or defend its territory. It roars menacingly, surrounded by broken weapons and bones. The adventurer attacks using his {weapon_equipment} or powerful magic. Torchlit environment, underground dungeons, or dense forests, or jagged mountains, or dark caves, or misty damp swamps. Unreal Engine render style, photorealistic, realistic fantasy style."
|
39 |
+
|
40 |
+
elif scene_dropdown == "Loot Bag":
|
41 |
+
prompt = f"A loot bag from a medieval fantasy adventurer and his equipments. On the floor also a {weapon_equipment} a {head_equipment}, a {hand_equipment}, a {chest_equipment}, a {waist_equipment}, and a {foot_equipment}. Please sure to use only medieval items that were possble to be made in that period. Inside the bag {gold_equipment} gold coins. Atmospheric light, cavern, dungeon context. Torchlit environment. Unreal Engine render style, photorealistic, realistic fantasy style."
|
42 |
+
else:
|
43 |
+
pass
|
44 |
+
|
45 |
+
return adventurer, prompt
|
46 |
+
|
src/prompt_gen copy 4.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from metadata.metadata import fetch_metadata
|
2 |
+
|
3 |
+
def prompt_gen(adventurer_id, scene_dropdown):
|
4 |
+
adventurer = fetch_metadata(adventurer_id)
|
5 |
+
print(f"ANDRE {adventurer['name']}")
|
6 |
+
|
7 |
+
id = adventurer['id']
|
8 |
+
name = adventurer['name']
|
9 |
+
weapon_equipment = adventurer['weapon']
|
10 |
+
head_equipment = adventurer['head']
|
11 |
+
hand_equipment = adventurer['hand']
|
12 |
+
chest_equipment = adventurer['chest']
|
13 |
+
waist_equipment = adventurer['waist']
|
14 |
+
foot_equipment = adventurer['foot']
|
15 |
+
gold_equipment = adventurer['gold']
|
16 |
+
beast_last_battle = adventurer['beast']
|
17 |
+
|
18 |
+
# Check for weapon = None to fix eventual generator mistakes
|
19 |
+
if weapon_equipment == None:
|
20 |
+
weapon_sentence = "holding nothing in his hands"
|
21 |
+
else:
|
22 |
+
weapon_sentence = f"holding only a {weapon_equipment}"
|
23 |
+
|
24 |
+
# if character_dropdown == "Wizard":
|
25 |
+
# character_attack_sentence = f"The adventurer is attacking using powerful magic"
|
26 |
+
# else:
|
27 |
+
# character_attack_sentence = f"The adventurer is attacking using his {weapon_equipment}"
|
28 |
+
|
29 |
+
|
30 |
+
# Set the custom prompt variables
|
31 |
+
if scene_dropdown == "Adventurer Portait":
|
32 |
+
prompt = f"A portait of a medieval, fantasy adventurer, {weapon_sentence}. He is also equiped in the head with a {head_equipment}, the hands with {hand_equipment}, the chest with a {chest_equipment}, and the waist with a {waist_equipment}. All equipments are strictly medieval, crafted from materials and techniques possible in that era. Make the adventurer unshaved and dirty, he have been figthing for days down into the dungeons. Torchlit light dungeon environment. Unreal Engine render style, photorealistic, atmospheric dark light, realistic fantasy style."
|
33 |
+
|
34 |
+
if scene_dropdown == "Beast Portait":
|
35 |
+
prompt = f"A massive {beast_last_battle} stands deep within the confines of a dark, foreboding dungeon. Its eyes glow faintly in the dark. It roars menacingly surrounded by broken weapons and bones of his past preys. Torchlit environment, underground dungeon. Unreal Engine render style, photorealistic, atmospheric dark lights, realistic fantasy style."
|
36 |
+
|
37 |
+
if scene_dropdown == "Last Battle":
|
38 |
+
prompt = f"A battle between a medieval fantasy adventurer and a massive {beast_last_battle} deep within the confines of a dark, foreboding dungeon. The adventurer is {weapon_sentence}. He is equipped with {head_equipment} on his head, {hand_equipment} on his hands, {chest_equipment} on his chest, {waist_equipment} around his waist, and {foot_equipment} on his feet. All equipment is strictly medieval, crafted from materials and techniques possible in that era. The {beast_last_battle} stands in a dark undergroud dungeon. Its eyes glow faintly in the dark. It roars menacingly, surrounded by broken weapons, scattered bones, and the remnants of past adventurers who failed to defeat it. The adventurer attacks using his {weapon_equipment} or powerful magic, the glow of his spells or the glint of his weapon illuminating the damp, moss-covered stone walls. The air is thick with the scent of mildew and blood, and the sound of dripping water echoes in the distance. Unreal Engine render style, photorealistic, realistic fantasy style."
|
39 |
+
|
40 |
+
elif scene_dropdown == "Loot Bag":
|
41 |
+
prompt = f"A loot bag from a medieval fantasy adventurer and his equipments. On the floor also a {weapon_equipment} a {head_equipment}, a {hand_equipment}, a {chest_equipment}, a {waist_equipment}, and a {foot_equipment}. All equipment is strictly medieval, crafted from materials and techniques possible in that era. Inside the bag {gold_equipment} gold coins. Atmospheric light, underground dungeon context. Torchlit environment. Unreal Engine render style, photorealistic, realistic fantasy style."
|
42 |
+
else:
|
43 |
+
pass
|
44 |
+
|
45 |
+
return adventurer, prompt
|
46 |
+
|
src/prompt_gen.py
CHANGED
@@ -17,7 +17,7 @@ def prompt_gen(adventurer_id, scene_dropdown):
|
|
17 |
|
18 |
# Check for weapon = None to fix eventual generator mistakes
|
19 |
if weapon_equipment == None:
|
20 |
-
|
21 |
else:
|
22 |
weapon_sentence = f"holding only a {weapon_equipment}"
|
23 |
|
@@ -26,19 +26,73 @@ def prompt_gen(adventurer_id, scene_dropdown):
|
|
26 |
# else:
|
27 |
# character_attack_sentence = f"The adventurer is attacking using his {weapon_equipment}"
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Set the custom prompt variables
|
31 |
if scene_dropdown == "Adventurer Portait":
|
32 |
-
prompt = f"A
|
33 |
-
|
34 |
if scene_dropdown == "Beast Portait":
|
35 |
-
prompt = f"A massive {beast_last_battle}
|
|
|
|
|
|
|
36 |
|
37 |
if scene_dropdown == "Last Battle":
|
38 |
-
prompt = f"A battle between a medieval fantasy adventurer
|
39 |
|
40 |
elif scene_dropdown == "Loot Bag":
|
41 |
-
prompt = f"A loot bag from a medieval fantasy adventurer and his equipments. On the floor also a {weapon_equipment} a {head_equipment}, a {hand_equipment}, a {chest_equipment}, a {waist_equipment}, and a {foot_equipment}.
|
42 |
else:
|
43 |
pass
|
44 |
|
|
|
17 |
|
18 |
# Check for weapon = None to fix eventual generator mistakes
|
19 |
if weapon_equipment == None:
|
20 |
+
weapon_equipment = "barehands"
|
21 |
else:
|
22 |
weapon_sentence = f"holding only a {weapon_equipment}"
|
23 |
|
|
|
26 |
# else:
|
27 |
# character_attack_sentence = f"The adventurer is attacking using his {weapon_equipment}"
|
28 |
|
29 |
+
# Function to build equipment sentence dynamically
|
30 |
+
def build_equipment_sentence(**equipment):
|
31 |
+
sentences = []
|
32 |
+
|
33 |
+
# Weapon
|
34 |
+
if equipment.get("weapon_equipment"):
|
35 |
+
sentences.append(f"holding a {equipment['weapon_equipment']}")
|
36 |
+
else:
|
37 |
+
sentences.append("holding nothing in his hands (bare hands)")
|
38 |
+
|
39 |
+
# Head
|
40 |
+
if equipment.get("head_equipment"):
|
41 |
+
sentences.append(f"wearing a {equipment['head_equipment']} on his head")
|
42 |
+
else:
|
43 |
+
sentences.append("with no head protection (bare head)")
|
44 |
+
|
45 |
+
# Hands
|
46 |
+
if equipment.get("hand_equipment"):
|
47 |
+
sentences.append(f"wearing {equipment['hand_equipment']} on his hands")
|
48 |
+
else:
|
49 |
+
sentences.append("with no hand protection (bare hands)")
|
50 |
+
|
51 |
+
# Chest
|
52 |
+
if equipment.get("chest_equipment"):
|
53 |
+
sentences.append(f"wearing a {equipment['chest_equipment']} on his chest")
|
54 |
+
else:
|
55 |
+
sentences.append("with no chest armor (bare chest)")
|
56 |
+
|
57 |
+
# Waist
|
58 |
+
if equipment.get("waist_equipment"):
|
59 |
+
sentences.append(f"wearing a {equipment['waist_equipment']} around his waist")
|
60 |
+
else:
|
61 |
+
sentences.append("with no waist equipment (bare waist)")
|
62 |
+
|
63 |
+
# Feet
|
64 |
+
if equipment.get("foot_equipment"):
|
65 |
+
sentences.append(f"wearing {equipment['foot_equipment']} on his feet")
|
66 |
+
else:
|
67 |
+
sentences.append("with no foot protection (bare feet)")
|
68 |
+
|
69 |
+
return ", ".join(sentences)
|
70 |
+
|
71 |
+
# Example usage
|
72 |
+
equipment_sentence = build_equipment_sentence(
|
73 |
+
weapon_equipment=weapon_equipment,
|
74 |
+
head_equipment=head_equipment,
|
75 |
+
hand_equipment=hand_equipment,
|
76 |
+
chest_equipment=chest_equipment,
|
77 |
+
waist_equipment=waist_equipment,
|
78 |
+
foot_equipment=foot_equipment
|
79 |
+
)
|
80 |
|
81 |
# Set the custom prompt variables
|
82 |
if scene_dropdown == "Adventurer Portait":
|
83 |
+
prompt = f"A portrait of a medieval, fantasy adventurer, {equipment_sentence}. All equipment is strictly medieval, crafted from materials and techniques possible in that era. Make the adventurer unshaved and dirty, as if he has been fighting for days down in the dungeons. Torchlit light environment. Foreboding dungeon scene. Unreal Engine render style, photorealistic, atmospheric dark light, realistic fantasy style."
|
84 |
+
|
85 |
if scene_dropdown == "Beast Portait":
|
86 |
+
prompt = f"A portait of a massive {beast_last_battle} in a dark, foreboding dungeon. Its eyes glow faintly in the dark. It roars menacingly surrounded by broken weapons and bones of his past preys. Torchlit environment, underground dungeon. Unreal Engine render style, photorealistic, atmospheric dark lights, realistic fantasy style."
|
87 |
+
|
88 |
+
if scene_dropdown == "Encounter":
|
89 |
+
prompt = f"A close-up shot of the {beast_last_battle}'s piercing eye, glowing faintly in the dim light of a torchlit dungeon. Intricate details of the beast's scaly or furred skin surround the eye, with faint scars and ancient markings hinting at its long history of battles. Torchlit environment. The atmosphere is tense, with shadows dancing across the dungeon walls and the faint glint of broken weapons and bones scattered nearby. Unreal Engine render style, photorealistic, atmospheric dark lighting, hyper-detailed, realistic fantasy style."
|
90 |
|
91 |
if scene_dropdown == "Last Battle":
|
92 |
+
prompt = f"A battle between a medieval fantasy adventurer and a massive {beast_last_battle} deep within the confines of a dark, foreboding dungeon. The adventurer is {equipment_sentence}. All equipment is strictly medieval, crafted from materials and techniques possible in that era. The {beast_last_battle} stands in a dark undergroud dungeon. Its eyes glow faintly in the dark. It roars menacingly, surrounded by broken weapons and bones of his past preys. The adventurer attacks using his {weapon_equipment} or powerful magic, the glow of his spells or the glint of his weapon illuminating the stone walls. The dungeon is dimly lit by flickering torches, their light casting long, ominous shadows across the ancient, cracked floor. Unreal Engine render style, photorealistic, realistic fantasy style."
|
93 |
|
94 |
elif scene_dropdown == "Loot Bag":
|
95 |
+
prompt = f"A loot bag from a medieval fantasy adventurer and his equipments. On the floor also a {weapon_equipment} a {head_equipment}, a {hand_equipment}, a {chest_equipment}, a {waist_equipment}, and a {foot_equipment}. All equipment is strictly medieval, crafted from materials and techniques possible in that era. Inside the bag {gold_equipment} gold coins. Atmospheric light, underground dungeon context. Torchlit environment. Unreal Engine render style, photorealistic, realistic fantasy style."
|
96 |
else:
|
97 |
pass
|
98 |
|
src/temp.py
CHANGED
@@ -18,4 +18,6 @@ Dungeon context, stones, fire and low light.
|
|
18 |
|
19 |
|
20 |
keywords:
|
21 |
-
|
|
|
|
|
|
18 |
|
19 |
|
20 |
keywords:
|
21 |
+
Torchlit environment
|
22 |
+
Its eyes glow faintly in the dark
|
23 |
+
The dungeon is dimly lit by flickering torches, their light casting long, ominous shadows across the ancient, cracked floor.
|