Spaces:
Running
on
Zero
Running
on
Zero
prepare spaces
Browse files- .dockerignore +7 -0
- Dockerfile.backend +3 -1
- README.md +0 -0
- app.py +2 -2
- docker-compose.yml +3 -3
- anime.py β scripts/anime.py +3 -4
- data.py β scripts/data.py +0 -0
- generate_prompt.py β scripts/generate_prompt.py +0 -0
- hf_utils.py β scripts/hf_utils.py +0 -0
- lineart_util.py β scripts/lineart_util.py +1 -1
- model.py β scripts/model.py +1 -1
- process_utils.py β scripts/process_utils.py +3 -3
- templates/index.html +0 -60
.dockerignore
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
models/
|
2 |
+
__pycache__/
|
3 |
+
venv/
|
4 |
+
output/
|
5 |
+
hf_gradio/
|
6 |
+
hf_cache/
|
7 |
+
wd14_tagger_model/
|
Dockerfile.backend
CHANGED
@@ -30,6 +30,8 @@ RUN apt -y install libopencv-dev
|
|
30 |
RUN pip install --no-cache-dir -r requirements.txt
|
31 |
RUN pip install --no-dependencies transformers
|
32 |
|
33 |
-
|
|
|
|
|
34 |
|
35 |
CMD ["python", "app.py", "--use_gpu"]
|
|
|
30 |
RUN pip install --no-cache-dir -r requirements.txt
|
31 |
RUN pip install --no-dependencies transformers
|
32 |
|
33 |
+
COPY . /app
|
34 |
+
|
35 |
+
EXPOSE 80
|
36 |
|
37 |
CMD ["python", "app.py", "--use_gpu"]
|
README.md
ADDED
File without changes
|
app.py
CHANGED
@@ -13,7 +13,7 @@ import queue
|
|
13 |
import threading
|
14 |
import uuid
|
15 |
import concurrent.futures
|
16 |
-
from process_utils import *
|
17 |
|
18 |
app = Flask(__name__)
|
19 |
# app.secret_key = 'super_secret_key'
|
@@ -190,4 +190,4 @@ if __name__ == '__main__':
|
|
190 |
args = parser.parse_args()
|
191 |
|
192 |
initialize(args.use_local, args.use_gpu)
|
193 |
-
socketio.run(app, debug=True, host='0.0.0.0', port=
|
|
|
13 |
import threading
|
14 |
import uuid
|
15 |
import concurrent.futures
|
16 |
+
from scripts.process_utils import *
|
17 |
|
18 |
app = Flask(__name__)
|
19 |
# app.secret_key = 'super_secret_key'
|
|
|
190 |
args = parser.parse_args()
|
191 |
|
192 |
initialize(args.use_local, args.use_gpu)
|
193 |
+
socketio.run(app, debug=True, host='0.0.0.0', port=80)
|
docker-compose.yml
CHANGED
@@ -4,9 +4,9 @@ services:
|
|
4 |
context: .
|
5 |
dockerfile: Dockerfile.backend
|
6 |
ports:
|
7 |
-
- "
|
8 |
-
volumes:
|
9 |
-
|
10 |
env_file:
|
11 |
- .env
|
12 |
deploy:
|
|
|
4 |
context: .
|
5 |
dockerfile: Dockerfile.backend
|
6 |
ports:
|
7 |
+
- "80:5000"
|
8 |
+
# volumes:
|
9 |
+
# - .:/app
|
10 |
env_file:
|
11 |
- .env
|
12 |
deploy:
|
anime.py β scripts/anime.py
RENAMED
@@ -6,10 +6,9 @@ Example:
|
|
6 |
|
7 |
import os
|
8 |
import torch
|
9 |
-
from
|
10 |
-
from
|
11 |
-
from
|
12 |
-
from data import read_img_path, tensor_to_img, save_image
|
13 |
import argparse
|
14 |
from tqdm.auto import tqdm
|
15 |
from kornia.enhance import equalize_clahe
|
|
|
6 |
|
7 |
import os
|
8 |
import torch
|
9 |
+
from scripts.data import get_image_list, get_transform
|
10 |
+
from scripts.model import create_model
|
11 |
+
from scripts.data import tensor_to_img, save_image
|
|
|
12 |
import argparse
|
13 |
from tqdm.auto import tqdm
|
14 |
from kornia.enhance import equalize_clahe
|
data.py β scripts/data.py
RENAMED
File without changes
|
generate_prompt.py β scripts/generate_prompt.py
RENAMED
File without changes
|
hf_utils.py β scripts/hf_utils.py
RENAMED
File without changes
|
lineart_util.py β scripts/lineart_util.py
RENAMED
@@ -1,7 +1,7 @@
|
|
1 |
import cv2
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
-
from anime import generate_sketch
|
5 |
|
6 |
def pad64(x):
|
7 |
return int(np.ceil(float(x) / 64.0) * 64 - x)
|
|
|
1 |
import cv2
|
2 |
import numpy as np
|
3 |
from PIL import Image
|
4 |
+
from scripts.anime import generate_sketch
|
5 |
|
6 |
def pad64(x):
|
7 |
return int(np.ceil(float(x) / 64.0) * 64 - x)
|
model.py β scripts/model.py
RENAMED
@@ -2,7 +2,7 @@ import torch
|
|
2 |
import torch.nn as nn
|
3 |
import torch.nn.functional as F
|
4 |
import functools
|
5 |
-
from hf_utils import download_file
|
6 |
|
7 |
class UnetGenerator(nn.Module):
|
8 |
"""Create a Unet-based generator"""
|
|
|
2 |
import torch.nn as nn
|
3 |
import torch.nn.functional as F
|
4 |
import functools
|
5 |
+
from scripts.hf_utils import download_file
|
6 |
|
7 |
class UnetGenerator(nn.Module):
|
8 |
"""Create a Unet-based generator"""
|
process_utils.py β scripts/process_utils.py
RENAMED
@@ -4,14 +4,14 @@ import base64
|
|
4 |
from PIL import Image
|
5 |
import cv2
|
6 |
import numpy as np
|
7 |
-
from generate_prompt import load_wd14_tagger_model, generate_tags, preprocess_image as wd14_preprocess_image
|
8 |
-
from lineart_util import scribble_xdog, get_sketch, canny
|
9 |
import torch
|
10 |
from diffusers import StableDiffusionPipeline, StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler, AutoencoderKL
|
11 |
import gc
|
12 |
from peft import PeftModel
|
13 |
from dotenv import load_dotenv
|
14 |
-
from hf_utils import download_file
|
15 |
|
16 |
# γ°γγΌγγ«ε€ζ°
|
17 |
use_local = False
|
|
|
4 |
from PIL import Image
|
5 |
import cv2
|
6 |
import numpy as np
|
7 |
+
from scripts.generate_prompt import load_wd14_tagger_model, generate_tags, preprocess_image as wd14_preprocess_image
|
8 |
+
from scripts.lineart_util import scribble_xdog, get_sketch, canny
|
9 |
import torch
|
10 |
from diffusers import StableDiffusionPipeline, StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler, AutoencoderKL
|
11 |
import gc
|
12 |
from peft import PeftModel
|
13 |
from dotenv import load_dotenv
|
14 |
+
from scripts.hf_utils import download_file
|
15 |
|
16 |
# γ°γγΌγγ«ε€ζ°
|
17 |
use_local = False
|
templates/index.html
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Scribble Image Generator</title>
|
7 |
-
<style>
|
8 |
-
body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
|
9 |
-
.image-container { display: flex; justify-content: space-between; margin-top: 20px; }
|
10 |
-
.image-container img { max-width: 48%; height: auto; }
|
11 |
-
#loading { display: none; }
|
12 |
-
</style>
|
13 |
-
</head>
|
14 |
-
<body>
|
15 |
-
<h1>Scribble Image Generator</h1>
|
16 |
-
<form id="upload-form">
|
17 |
-
<input type="file" id="file-input" accept="image/*" required>
|
18 |
-
<br><br>
|
19 |
-
<label for="threshold">Threshold:</label>
|
20 |
-
<input type="number" id="threshold" name="threshold" value="20" min="1" max="64">
|
21 |
-
<br><br>
|
22 |
-
<label for="processor_res">Processor Resolution:</label>
|
23 |
-
<input type="number" id="processor_res" name="processor_res" value="2048" min="64" max="2048">
|
24 |
-
<br><br>
|
25 |
-
<button type="submit">Generate Scribble</button>
|
26 |
-
</form>
|
27 |
-
<div id="loading">Processing...</div>
|
28 |
-
<div class="image-container">
|
29 |
-
<img id="original-image" alt="Original Image">
|
30 |
-
<img id="scribble-image" alt="Scribble Image">
|
31 |
-
</div>
|
32 |
-
|
33 |
-
<script>
|
34 |
-
document.getElementById('upload-form').addEventListener('submit', function(e) {
|
35 |
-
e.preventDefault();
|
36 |
-
var formData = new FormData();
|
37 |
-
formData.append('file', document.getElementById('file-input').files[0]);
|
38 |
-
formData.append('threshold', document.getElementById('threshold').value);
|
39 |
-
formData.append('processor_res', document.getElementById('processor_res').value);
|
40 |
-
|
41 |
-
document.getElementById('loading').style.display = 'block';
|
42 |
-
|
43 |
-
fetch('/process', {
|
44 |
-
method: 'POST',
|
45 |
-
body: formData
|
46 |
-
})
|
47 |
-
.then(response => response.json())
|
48 |
-
.then(data => {
|
49 |
-
document.getElementById('original-image').src = 'data:image/png;base64,' + data.original_image;
|
50 |
-
document.getElementById('scribble-image').src = 'data:image/png;base64,' + data.scribble_image;
|
51 |
-
document.getElementById('loading').style.display = 'none';
|
52 |
-
})
|
53 |
-
.catch(error => {
|
54 |
-
console.error('Error:', error);
|
55 |
-
document.getElementById('loading').style.display = 'none';
|
56 |
-
});
|
57 |
-
});
|
58 |
-
</script>
|
59 |
-
</body>
|
60 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|