oopshnik
commited on
Commit
Β·
68b014f
1
Parent(s):
871e175
- .devcontainer/devcontainer.json +33 -0
- .gitignore +16 -0
- .python-version +1 -0
- __init__.py +0 -0
- app.py +23 -23
.devcontainer/devcontainer.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "Python 3",
|
3 |
+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
4 |
+
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
|
5 |
+
"customizations": {
|
6 |
+
"codespaces": {
|
7 |
+
"openFiles": [
|
8 |
+
"README.md",
|
9 |
+
"images.py"
|
10 |
+
]
|
11 |
+
},
|
12 |
+
"vscode": {
|
13 |
+
"settings": {},
|
14 |
+
"extensions": [
|
15 |
+
"ms-python.python",
|
16 |
+
"ms-python.vscode-pylance"
|
17 |
+
]
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo 'β
Packages installed and Requirements met'",
|
21 |
+
"postAttachCommand": {
|
22 |
+
"server": "streamlit run images.py --server.enableCORS false --server.enableXsrfProtection false"
|
23 |
+
},
|
24 |
+
"portsAttributes": {
|
25 |
+
"8501": {
|
26 |
+
"label": "Application",
|
27 |
+
"onAutoForward": "openPreview"
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"forwardPorts": [
|
31 |
+
8501
|
32 |
+
]
|
33 |
+
}
|
.gitignore
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python-generated files
|
2 |
+
__pycache__/
|
3 |
+
*.py[oc]
|
4 |
+
build/
|
5 |
+
dist/
|
6 |
+
wheels/
|
7 |
+
*.egg-info
|
8 |
+
|
9 |
+
# Secrets
|
10 |
+
*.env
|
11 |
+
|
12 |
+
# Other stuffs
|
13 |
+
.devcotainer/
|
14 |
+
images/
|
15 |
+
# Virtual environments
|
16 |
+
.venv
|
.python-version
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
3.11
|
__init__.py
ADDED
File without changes
|
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import subprocess
|
|
|
4 |
from urllib.parse import quote
|
5 |
from io import BytesIO
|
6 |
|
@@ -38,17 +39,21 @@ st.markdown("""
|
|
38 |
</style>
|
39 |
""", unsafe_allow_html=True)
|
40 |
|
41 |
-
st.markdown("<h1 class='title-text'>π¨ AI Image Generator</h1>", unsafe_allow_html=True)
|
42 |
|
43 |
with st.sidebar:
|
44 |
st.header("βοΈ Settings")
|
45 |
|
46 |
-
width = st.slider("Width:", 256, 2048,
|
47 |
-
height = st.slider("Height:", 256, 2048,
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
|
53 |
model = st.selectbox("Model:", ["flux", "flux-pro", "flux-realism", "flux-anime", "flux-3d", "flux-cablyai", "turbo"], index=0)
|
54 |
|
@@ -56,12 +61,16 @@ with st.sidebar:
|
|
56 |
nologo = st.checkbox("Remove Watermark", value=True)
|
57 |
private = st.checkbox("Keep image private", value=True)
|
58 |
enhance = st.checkbox("Enhance prompt", value=True)
|
|
|
59 |
|
60 |
st.subheader("βΉοΈ About")
|
61 |
st.markdown("""
|
62 |
-
[](https://github.com/oopshnik/image_gen)
|
64 |
-
[![
|
|
|
|
|
|
|
65 |
""", unsafe_allow_html=True)
|
66 |
|
67 |
st.markdown("<h3 style='text-align: center;'>Enter Your Image Prompt</h3>", unsafe_allow_html=True)
|
@@ -69,7 +78,6 @@ col1, col2, col3 = st.columns([1, 3, 1])
|
|
69 |
with col2:
|
70 |
prompt = st.text_input("Prompt:", placeholder="A futuristic city at sunset π", label_visibility="collapsed")
|
71 |
|
72 |
-
|
73 |
col1, col2, col3 = st.columns([1, 2, 1])
|
74 |
|
75 |
with col2:
|
@@ -87,24 +95,16 @@ with col2:
|
|
87 |
"private": str(private).lower(),
|
88 |
"enhance": str(enhance).lower(),
|
89 |
"model": model,
|
90 |
-
"safe":
|
91 |
}
|
92 |
url = f"{base_url}{encoded_prompt}?" + "&".join([f"{k}={v}" for k, v in params.items()])
|
93 |
-
|
94 |
response = requests.get(url)
|
95 |
|
96 |
if response.status_code == 200:
|
97 |
-
img_bytes = BytesIO(response.content)
|
98 |
-
process = subprocess.run(["curl", "-f", "-X", "POST", "-F", "file=@-", "https://0x0.st"],
|
99 |
-
input=img_bytes.getvalue(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
100 |
-
|
101 |
-
if process.returncode == 0:
|
102 |
-
upload_url = process.stdout.decode().strip()
|
103 |
-
|
104 |
-
|
105 |
-
st.image(response.content, caption=f"β¨ Generated Image \nπ {upload_url}", use_container_width=True)
|
106 |
-
st.success(f"β
Image generated successfully! Seed used: {seed} | Width: {width} | Height: {height}\n {upload_url}")
|
107 |
-
|
108 |
|
|
|
|
|
|
|
109 |
else:
|
110 |
-
st.error(f"β Failed to generate image. Status code: {response.status_code}")
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
import subprocess
|
4 |
+
import random
|
5 |
from urllib.parse import quote
|
6 |
from io import BytesIO
|
7 |
|
|
|
39 |
</style>
|
40 |
""", unsafe_allow_html=True)
|
41 |
|
42 |
+
st.markdown("<h1 style='background: linear-gradient(90deg, #ff7eb3, #ff758c); -webkit-background-clip: text; -webkit-text-fill-color: transparent;' class='title-text'>π¨ AI Image Generator</h1>", unsafe_allow_html=True)
|
43 |
|
44 |
with st.sidebar:
|
45 |
st.header("βοΈ Settings")
|
46 |
|
47 |
+
width = st.slider("Width:", 256, 2048, 512, step=1)
|
48 |
+
height = st.slider("Height:", 256, 2048, 512, step=1)
|
49 |
|
50 |
+
random_seed = st.checkbox("Use Random Seed", value=True)
|
51 |
+
if random_seed:
|
52 |
+
seed = random.randint(1, 1337)
|
53 |
+
else:
|
54 |
+
if "seed" not in st.session_state:
|
55 |
+
st.session_state.seed = 42
|
56 |
+
seed = st.number_input("Seed:", value=st.session_state.seed, min_value=1, max_value=1337, step=1)
|
57 |
|
58 |
model = st.selectbox("Model:", ["flux", "flux-pro", "flux-realism", "flux-anime", "flux-3d", "flux-cablyai", "turbo"], index=0)
|
59 |
|
|
|
61 |
nologo = st.checkbox("Remove Watermark", value=True)
|
62 |
private = st.checkbox("Keep image private", value=True)
|
63 |
enhance = st.checkbox("Enhance prompt", value=True)
|
64 |
+
safe = st.checkbox("Safe", value=True)
|
65 |
|
66 |
st.subheader("βΉοΈ About")
|
67 |
st.markdown("""
|
68 |
+
[](https://pollinations.ai)
|
69 |
[](https://github.com/oopshnik/image_gen)
|
70 |
+
[](https://huggingface.co/spaces/oopshnik/image_gen)
|
71 |
+
\n
|
72 |
+
[](https://t.me/pr_ogr)
|
73 |
+
|
74 |
""", unsafe_allow_html=True)
|
75 |
|
76 |
st.markdown("<h3 style='text-align: center;'>Enter Your Image Prompt</h3>", unsafe_allow_html=True)
|
|
|
78 |
with col2:
|
79 |
prompt = st.text_input("Prompt:", placeholder="A futuristic city at sunset π", label_visibility="collapsed")
|
80 |
|
|
|
81 |
col1, col2, col3 = st.columns([1, 2, 1])
|
82 |
|
83 |
with col2:
|
|
|
95 |
"private": str(private).lower(),
|
96 |
"enhance": str(enhance).lower(),
|
97 |
"model": model,
|
98 |
+
"safe": str(safe).lower()
|
99 |
}
|
100 |
url = f"{base_url}{encoded_prompt}?" + "&".join([f"{k}={v}" for k, v in params.items()])
|
101 |
+
|
102 |
response = requests.get(url)
|
103 |
|
104 |
if response.status_code == 200:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
+
st.image(response.content, caption=f"β¨ Generated Image", width=width)
|
107 |
+
st.download_button('π₯ Download Image', data=response.content, file_name=prompt+".png", mime="image/png")
|
108 |
+
st.code("")
|
109 |
else:
|
110 |
+
st.error(f"β Failed to generate image. Status code: {response.status_code}")
|