Spaces:
Runtime error
Runtime error
init
Browse files- .gitignore +162 -0
- app.py +89 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
temp/
|
24 |
+
/models/
|
25 |
+
output/
|
26 |
+
share/python-wheels/
|
27 |
+
*.egg-info/
|
28 |
+
.installed.cfg
|
29 |
+
*.egg
|
30 |
+
MANIFEST
|
31 |
+
|
32 |
+
# PyInstaller
|
33 |
+
# Usually these files are written by a python script from a template
|
34 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
35 |
+
*.manifest
|
36 |
+
*.spec
|
37 |
+
|
38 |
+
# Installer logs
|
39 |
+
pip-log.txt
|
40 |
+
pip-delete-this-directory.txt
|
41 |
+
|
42 |
+
# Unit test / coverage reports
|
43 |
+
htmlcov/
|
44 |
+
.tox/
|
45 |
+
.nox/
|
46 |
+
.coverage
|
47 |
+
.coverage.*
|
48 |
+
.cache
|
49 |
+
nosetests.xml
|
50 |
+
coverage.xml
|
51 |
+
*.cover
|
52 |
+
*.py,cover
|
53 |
+
.hypothesis/
|
54 |
+
.pytest_cache/
|
55 |
+
cover/
|
56 |
+
|
57 |
+
# Translations
|
58 |
+
*.mo
|
59 |
+
*.pot
|
60 |
+
|
61 |
+
# Django stuff:
|
62 |
+
*.log
|
63 |
+
local_settings.py
|
64 |
+
db.sqlite3
|
65 |
+
db.sqlite3-journal
|
66 |
+
|
67 |
+
# Flask stuff:
|
68 |
+
instance/
|
69 |
+
.webassets-cache
|
70 |
+
|
71 |
+
# Scrapy stuff:
|
72 |
+
.scrapy
|
73 |
+
|
74 |
+
# Sphinx documentation
|
75 |
+
docs/_build/
|
76 |
+
|
77 |
+
# PyBuilder
|
78 |
+
.pybuilder/
|
79 |
+
target/
|
80 |
+
|
81 |
+
# Jupyter Notebook
|
82 |
+
.ipynb_checkpoints
|
83 |
+
|
84 |
+
# IPython
|
85 |
+
profile_default/
|
86 |
+
ipython_config.py
|
87 |
+
|
88 |
+
# pyenv
|
89 |
+
# For a library or package, you might want to ignore these files since the code is
|
90 |
+
# intended to run in multiple environments; otherwise, check them in:
|
91 |
+
# .python-version
|
92 |
+
|
93 |
+
# pipenv
|
94 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
95 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
96 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
97 |
+
# install all needed dependencies.
|
98 |
+
#Pipfile.lock
|
99 |
+
|
100 |
+
# poetry
|
101 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
102 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
103 |
+
# commonly ignored for libraries.
|
104 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
105 |
+
#poetry.lock
|
106 |
+
|
107 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
108 |
+
__pypackages__/
|
109 |
+
|
110 |
+
# Celery stuff
|
111 |
+
celerybeat-schedule
|
112 |
+
celerybeat.pid
|
113 |
+
|
114 |
+
# SageMath parsed files
|
115 |
+
*.sage.py
|
116 |
+
|
117 |
+
# Environments
|
118 |
+
.env
|
119 |
+
.venv
|
120 |
+
env/
|
121 |
+
venv/
|
122 |
+
ENV/
|
123 |
+
env.bak/
|
124 |
+
venv.bak/
|
125 |
+
|
126 |
+
# Spyder project settings
|
127 |
+
.spyderproject
|
128 |
+
.spyproject
|
129 |
+
|
130 |
+
# Rope project settings
|
131 |
+
.ropeproject
|
132 |
+
|
133 |
+
# mkdocs documentation
|
134 |
+
/site
|
135 |
+
|
136 |
+
# mypy
|
137 |
+
.mypy_cache/
|
138 |
+
.dmypy.json
|
139 |
+
dmypy.json
|
140 |
+
|
141 |
+
# Pyre type checker
|
142 |
+
.pyre/
|
143 |
+
|
144 |
+
# pytype static type analyzer
|
145 |
+
.pytype/
|
146 |
+
|
147 |
+
# Cython debug symbols
|
148 |
+
cython_debug/
|
149 |
+
|
150 |
+
# PyCharm
|
151 |
+
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
|
152 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
153 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
154 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
155 |
+
.idea
|
156 |
+
|
157 |
+
nohup.out
|
158 |
+
|
159 |
+
*.env
|
160 |
+
/Real-ESRGAN/
|
161 |
+
venv
|
162 |
+
flagged
|
app.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import io
|
3 |
+
import json
|
4 |
+
import os
|
5 |
+
|
6 |
+
import aiohttp
|
7 |
+
from PIL import Image
|
8 |
+
from dotenv import load_dotenv
|
9 |
+
load_dotenv()
|
10 |
+
import PIL
|
11 |
+
|
12 |
+
API_URL = os.getenv("API_URL")
|
13 |
+
API_KEY = os.getenv("API_KEY")
|
14 |
+
|
15 |
+
import gradio as gr
|
16 |
+
|
17 |
+
|
18 |
+
async def load_image_from_url(url):
|
19 |
+
async with aiohttp.ClientSession() as session:
|
20 |
+
async with session.get(url) as response:
|
21 |
+
image_data = await response.read()
|
22 |
+
return Image.open(io.BytesIO(image_data))
|
23 |
+
|
24 |
+
async def greet(prompt):
|
25 |
+
|
26 |
+
url = API_URL
|
27 |
+
headers = {
|
28 |
+
'x-qrbtf-key': f'{API_KEY}',
|
29 |
+
}
|
30 |
+
|
31 |
+
full_response: str = ""
|
32 |
+
|
33 |
+
payload = {
|
34 |
+
'url': 'https://qrbtf.com/',
|
35 |
+
'prompt': prompt,
|
36 |
+
}
|
37 |
+
|
38 |
+
async with aiohttp.ClientSession(headers=headers) as session:
|
39 |
+
|
40 |
+
async with session.post(url, json=payload, ssl=False) as response:
|
41 |
+
|
42 |
+
await asyncio.sleep(0)
|
43 |
+
|
44 |
+
async for (chunk, _) in response.content.iter_chunks():
|
45 |
+
chunk = json.loads(chunk.decode("utf-8"))
|
46 |
+
if chunk["type"] == "result":
|
47 |
+
data = chunk["data"]
|
48 |
+
url = data["download_url"]
|
49 |
+
print(url)
|
50 |
+
return await load_image_from_url(url)
|
51 |
+
|
52 |
+
return full_response
|
53 |
+
|
54 |
+
|
55 |
+
with gr.Blocks() as demo:
|
56 |
+
gr.Markdown("""
|
57 |
+
|
58 |
+
# QRBTF.AI API Demo
|
59 |
+
|
60 |
+
- [Join Discord](https://discord.gg/V9CNuqYfte)
|
61 |
+
- [Official website](https://qrbtf.com/)
|
62 |
+
|
63 |
+
""")
|
64 |
+
with gr.Row():
|
65 |
+
with gr.Column():
|
66 |
+
url = gr.Textbox(
|
67 |
+
label="URL",
|
68 |
+
placeholder="https://",
|
69 |
+
value="https://qrbtf.com/",
|
70 |
+
interactive=False
|
71 |
+
)
|
72 |
+
prompt = gr.Textbox(
|
73 |
+
label="Prompt",
|
74 |
+
placeholder="Enter a prompt here",
|
75 |
+
)
|
76 |
+
with gr.Row():
|
77 |
+
clear_btn = gr.Button(
|
78 |
+
"Clear",
|
79 |
+
)
|
80 |
+
btn = gr.Button(
|
81 |
+
"Call API",
|
82 |
+
variant="primary"
|
83 |
+
)
|
84 |
+
with gr.Column():
|
85 |
+
out = gr.Image()
|
86 |
+
btn.click(fn=greet, inputs=prompt, outputs=out)
|
87 |
+
clear_btn.click(fn=lambda: prompt.update(""))
|
88 |
+
|
89 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
python-dotenv
|
3 |
+
pillow
|