Compare commits
No commits in common. "109e06a5d620be3c8b2de49b7b076c76886dcdb3" and "f945eb462a8655a2b78175d1925ed5b0235b0ebb" have entirely different histories.
109e06a5d6
...
f945eb462a
@ -1,4 +1,3 @@
|
||||
env
|
||||
.git
|
||||
**/__pycache__
|
||||
q
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
env
|
||||
**/__pycache__
|
||||
q
|
||||
|
@ -13,4 +13,4 @@ RUN apt update && apt install -y ffmpeg libsm6 libxext6
|
||||
COPY src .
|
||||
COPY best.pt /best.pt
|
||||
|
||||
CMD [ "gunicorn", "-b 0.0.0.0:80", "--workers", "1", "app:app" ]
|
||||
CMD [ "gunicorn", "-b 0.0.0.0:80", "app:app" ]
|
||||
|
@ -5,4 +5,4 @@ services:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8759:80
|
||||
- 8759:8000
|
||||
|
19
index.html
19
index.html
@ -1,29 +1,17 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="https://alv.cx/styles.css" />
|
||||
<title>glass | alv.cx</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>find glass in an image!</h1>
|
||||
<img id="img" src="" />
|
||||
|
||||
<p id="statusline">submit an image to get started!</p>
|
||||
<form id="form" action="http://localhost:8759/submit" method="post">
|
||||
<form id="form" action="http://localhost:5000/submit" method="post">
|
||||
<input type="file" id="job" name="image" accept="image/png,image/jpeg" /><br>
|
||||
<button type="submit" id="submit">submit</button>
|
||||
</form>
|
||||
|
||||
<p> built with ❤ and adequate amounts of care by <a href="https://alv.cx">alv</a></p>
|
||||
|
||||
<script>
|
||||
const form = document.getElementById("form");
|
||||
const img = document.getElementById("img");
|
||||
const statusline = document.getElementById("statusline");
|
||||
|
||||
async function handleSubmit(ev) {
|
||||
statusline.innerHTML = "SUBMITTING"
|
||||
ev.preventDefault();
|
||||
const form = ev.currentTarget;
|
||||
const data = new FormData(form);
|
||||
@ -38,11 +26,11 @@
|
||||
console.log(id);
|
||||
|
||||
while (true) {
|
||||
const resp = await fetch('http://localhost:8759/state/' + id);
|
||||
const resp = await fetch('http://localhost:5000/state/' + id);
|
||||
const state = (await resp.json()).state;
|
||||
statusline.innerHTML = state;
|
||||
if (state == "READY") {
|
||||
img.src = 'http://localhost:8759/result/' + id
|
||||
img.src = 'http://localhost:5000/result/' + id
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -50,4 +38,3 @@
|
||||
|
||||
form.addEventListener('submit', handleSubmit)
|
||||
</script>
|
||||
</body>
|
||||
|
@ -6,7 +6,6 @@ contourpy==1.2.0
|
||||
cycler==0.12.1
|
||||
filelock==3.9.0
|
||||
Flask==3.0.0
|
||||
Flask-Cors==4.0.0
|
||||
fonttools==4.47.0
|
||||
fsspec==2023.4.0
|
||||
gunicorn==21.2.0
|
||||
|
14
src/app.py
14
src/app.py
@ -33,8 +33,7 @@ def process():
|
||||
print("created model")
|
||||
last = 0
|
||||
while True:
|
||||
# wait x seconds before processing another task
|
||||
if time.time() < last + 2:
|
||||
if time.time() < last + 10:
|
||||
print("aa")
|
||||
time.sleep(0.5)
|
||||
continue
|
||||
@ -44,7 +43,7 @@ def process():
|
||||
print("waiting for/getting job")
|
||||
job = q.get()
|
||||
filepath = root.joinpath(job)
|
||||
print("got job", flush=True)
|
||||
print("got job")
|
||||
state[job] = {
|
||||
'state': QUEUE_STATE_PROCESSING,
|
||||
}
|
||||
@ -62,12 +61,6 @@ def process():
|
||||
|
||||
filepath.unlink()
|
||||
|
||||
last = time.time()
|
||||
|
||||
|
||||
p = Thread(target=process)
|
||||
p.start()
|
||||
|
||||
|
||||
@app.route("/submit", methods=['POST'])
|
||||
def render():
|
||||
@ -91,4 +84,7 @@ def get_result(i):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
p = Thread(target=process)
|
||||
p.start()
|
||||
app.run(debug=True)
|
||||
p.join()
|
||||
|
Loading…
Reference in New Issue
Block a user