Spaces:
Sleeping
Sleeping
Commit ·
c52c0f1
1
Parent(s): 0760a96
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def generate_art(character_dropdown, seed_slider):
|
| 2 |
+
|
| 3 |
+
if character_dropdown == "NONE":
|
| 4 |
+
return "NULL"
|
| 5 |
+
else:
|
| 6 |
+
return "NOT NULL"
|
| 7 |
+
|
| 8 |
+
return "Hello There!"
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
HTML_TEMPLATE = """
|
| 12 |
+
<style>
|
| 13 |
+
|
| 14 |
+
#app-header {
|
| 15 |
+
text-align: center;
|
| 16 |
+
background: rgba(255, 255, 255, 0.8); /* Semi-transparent white */
|
| 17 |
+
padding: 20px;
|
| 18 |
+
border-radius: 10px;
|
| 19 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 20 |
+
position: relative; /* To position the artifacts */
|
| 21 |
+
}
|
| 22 |
+
#app-header h1 {
|
| 23 |
+
color: #f308eb;
|
| 24 |
+
font-size: 2em;
|
| 25 |
+
margin-bottom: 10px;
|
| 26 |
+
}
|
| 27 |
+
.concept {
|
| 28 |
+
position: relative;
|
| 29 |
+
transition: transform 0.3s;
|
| 30 |
+
}
|
| 31 |
+
.concept:hover {
|
| 32 |
+
transform: scale(1.1);
|
| 33 |
+
}
|
| 34 |
+
.concept img {
|
| 35 |
+
width: 100px;
|
| 36 |
+
border-radius: 10px;
|
| 37 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 38 |
+
}
|
| 39 |
+
.concept-description {
|
| 40 |
+
position: absolute;
|
| 41 |
+
bottom: -30px;
|
| 42 |
+
left: 50%;
|
| 43 |
+
transform: translateX(-50%);
|
| 44 |
+
background-color: #4CAF50;
|
| 45 |
+
color: white;
|
| 46 |
+
padding: 5px 10px;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
opacity: 0;
|
| 49 |
+
transition: opacity 0.3s;
|
| 50 |
+
}
|
| 51 |
+
.concept:hover .concept-description {
|
| 52 |
+
opacity: 1;
|
| 53 |
+
}
|
| 54 |
+
/* Artifacts */
|
| 55 |
+
|
| 56 |
+
</style>
|
| 57 |
+
<div id="app-header">
|
| 58 |
+
<!-- Artifacts -->
|
| 59 |
+
<div class="artifact large"></div>
|
| 60 |
+
<div class="artifact medium"></div>
|
| 61 |
+
<div class="artifact small"></div>
|
| 62 |
+
<!-- Content -->
|
| 63 |
+
<h1>Shakespeare Dialogue Generator</h1>
|
| 64 |
+
<p>Generate new dialogue for Shakespearean character by selecting character from dropdown.</p>
|
| 65 |
+
<div style="display: flex; justify-content: center; gap: 20px; margin-top: 20px;">
|
| 66 |
+
<div class="concept">
|
| 67 |
+
<img src="https://github.com/Delve-ERAV1/S20/assets/11761529/30ac92f8-fc62-4aab-9221-043865c6fe7c" alt="Romeo">
|
| 68 |
+
<div class="concept-description">Midjourney Style</div>
|
| 69 |
+
</div>
|
| 70 |
+
<div class="concept">
|
| 71 |
+
<img src="https://github.com/Delve-ERAV1/S20/assets/11761529/54c9a61e-df9f-4054-835b-ec2c6ba5916c" alt="Juliet">
|
| 72 |
+
<div class="concept-description">Dreams Style</div>
|
| 73 |
+
</div>
|
| 74 |
+
<div class="concept">
|
| 75 |
+
<img src="https://github.com/Delve-ERAV1/S20/assets/11761529/2f37e402-15d1-4a74-ba85-bb1566da930e" alt="MacBeth">
|
| 76 |
+
<div class="concept-description">Moebius Style</div>
|
| 77 |
+
</div>
|
| 78 |
+
<div class="concept">
|
| 79 |
+
<img src="https://github.com/Delve-ERAV1/S20/assets/11761529/f838e767-ac20-4996-b5be-65c61b365ce0" alt="A">
|
| 80 |
+
<div class="concept-description">Hong Kong born artist inspired by western and eastern influences</div>
|
| 81 |
+
</div>
|
| 82 |
+
<div class="concept">
|
| 83 |
+
<img src="https://github.com/Delve-ERAV1/S20/assets/11761529/9958140a-1b62-4972-83ca-85b023e3863f" alt="S">
|
| 84 |
+
<div class="concept-description">WLOP (Born 1987) is known for Digital Art (NFTs)</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
with gr.Blocks() as interface:
|
| 91 |
+
gr.HTML(value=HTML_TEMPLATE, show_label=False)
|
| 92 |
+
with gr.Row():
|
| 93 |
+
character_dropdown = gr.Dropdown(
|
| 94 |
+
label="Select a Character",
|
| 95 |
+
choices=["NONE","ROMEO","OPHELIA","DESDEMONA","MACDUFF"],
|
| 96 |
+
value='Dream'
|
| 97 |
+
)
|
| 98 |
+
seed_slider = gr.Slider(
|
| 99 |
+
label="Random Seed",
|
| 100 |
+
minimum=0,
|
| 101 |
+
maximum=1000,
|
| 102 |
+
step=1,
|
| 103 |
+
value=42
|
| 104 |
+
)
|
| 105 |
+
inputs = [character_dropdown, seed_slider]
|
| 106 |
+
|
| 107 |
+
with gr.Row():
|
| 108 |
+
outputs = gr.Textbox(
|
| 109 |
+
label="Generated Dialogue"
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
with gr.Row():
|
| 113 |
+
button = gr.Button("Generate Dialogue")
|
| 114 |
+
button.click(generate_art, inputs=inputs, outputs=outputs)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
if __name__ == "__main__":
|
| 118 |
+
interface.launch(enable_queue=True)
|