Spaces:
Sleeping
Sleeping
Commit
·
24c01fa
1
Parent(s):
044e983
commit
Browse files- Cap_VQA.html +155 -0
- Dockerfile +13 -0
- RRDBNet_arch.py +78 -0
- app.py +201 -0
- duckduck_images.csv +1 -0
- duckduck_tutorial.csv +101 -0
- net_interp.py +21 -0
- requirements.txt +0 -0
- similar_images.py +18 -0
- templates/index.html +369 -0
- tokenizer.json +0 -0
- transer_RRDB_models.py +55 -0
Cap_VQA.html
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Image Insight - Sign Up & Login</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
margin: 0;
|
11 |
+
padding: 0;
|
12 |
+
background: linear-gradient(to right, #6a11cb, #2575fc);
|
13 |
+
color: #fff;
|
14 |
+
display: flex;
|
15 |
+
justify-content: center;
|
16 |
+
align-items: center;
|
17 |
+
height: 100vh;
|
18 |
+
}
|
19 |
+
|
20 |
+
.container {
|
21 |
+
width: 90%;
|
22 |
+
max-width: 800px;
|
23 |
+
background: #ffffff;
|
24 |
+
color: #333;
|
25 |
+
border-radius: 8px;
|
26 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
27 |
+
display: flex;
|
28 |
+
overflow: hidden;
|
29 |
+
}
|
30 |
+
|
31 |
+
.form-container {
|
32 |
+
flex: 1;
|
33 |
+
padding: 40px 20px;
|
34 |
+
}
|
35 |
+
|
36 |
+
.form-container h2 {
|
37 |
+
margin-bottom: 20px;
|
38 |
+
text-align: center;
|
39 |
+
color: #2575fc;
|
40 |
+
}
|
41 |
+
|
42 |
+
.form-container form {
|
43 |
+
display: flex;
|
44 |
+
flex-direction: column;
|
45 |
+
}
|
46 |
+
|
47 |
+
.form-container form label {
|
48 |
+
margin-bottom: 8px;
|
49 |
+
font-size: 14px;
|
50 |
+
color: #666;
|
51 |
+
}
|
52 |
+
|
53 |
+
.form-container form input {
|
54 |
+
padding: 10px;
|
55 |
+
margin-bottom: 20px;
|
56 |
+
border: 1px solid #ddd;
|
57 |
+
border-radius: 4px;
|
58 |
+
font-size: 16px;
|
59 |
+
}
|
60 |
+
|
61 |
+
.form-container form button {
|
62 |
+
background: #2575fc;
|
63 |
+
color: #fff;
|
64 |
+
padding: 12px;
|
65 |
+
border: none;
|
66 |
+
border-radius: 4px;
|
67 |
+
font-size: 16px;
|
68 |
+
cursor: pointer;
|
69 |
+
transition: background 0.3s;
|
70 |
+
}
|
71 |
+
|
72 |
+
.form-container form button:hover {
|
73 |
+
background: #6a11cb;
|
74 |
+
}
|
75 |
+
|
76 |
+
.switch-container {
|
77 |
+
flex: 0.5;
|
78 |
+
background: #2575fc;
|
79 |
+
color: #fff;
|
80 |
+
display: flex;
|
81 |
+
flex-direction: column;
|
82 |
+
justify-content: center;
|
83 |
+
align-items: center;
|
84 |
+
padding: 40px 20px;
|
85 |
+
}
|
86 |
+
|
87 |
+
.switch-container h2 {
|
88 |
+
font-size: 24px;
|
89 |
+
margin-bottom: 20px;
|
90 |
+
}
|
91 |
+
|
92 |
+
.switch-container p {
|
93 |
+
margin-bottom: 20px;
|
94 |
+
font-size: 14px;
|
95 |
+
text-align: center;
|
96 |
+
}
|
97 |
+
|
98 |
+
.switch-container button {
|
99 |
+
background: #fff;
|
100 |
+
color: #2575fc;
|
101 |
+
padding: 10px 20px;
|
102 |
+
border: none;
|
103 |
+
border-radius: 4px;
|
104 |
+
font-size: 16px;
|
105 |
+
cursor: pointer;
|
106 |
+
transition: background 0.3s;
|
107 |
+
}
|
108 |
+
|
109 |
+
.switch-container button:hover {
|
110 |
+
background: #f1f1f1;
|
111 |
+
}
|
112 |
+
</style>
|
113 |
+
</head>
|
114 |
+
<body>
|
115 |
+
<div class="container">
|
116 |
+
<!-- Login Form -->
|
117 |
+
<div class="form-container">
|
118 |
+
<h2>Login to Image Insight</h2>
|
119 |
+
<form>
|
120 |
+
<label for="login-email">Email</label>
|
121 |
+
<input type="email" id="login-email" placeholder="Enter your email" required>
|
122 |
+
<label for="login-password">Password</label>
|
123 |
+
<input type="password" id="login-password" placeholder="Enter your password" required>
|
124 |
+
<button type="submit">Login</button>
|
125 |
+
</form>
|
126 |
+
</div>
|
127 |
+
<!-- Switch Section -->
|
128 |
+
<div class="switch-container">
|
129 |
+
<h2>New Here?</h2>
|
130 |
+
<p>Sign up to use our Image Captioning and VQA features.</p>
|
131 |
+
<button onclick="switchToSignUp()">Sign Up</button>
|
132 |
+
</div>
|
133 |
+
<!-- Sign Up Form -->
|
134 |
+
<div class="form-container" style="display: none;">
|
135 |
+
<h2>Sign Up for Image Insight</h2>
|
136 |
+
<form>
|
137 |
+
<label for="signup-name">Full Name</label>
|
138 |
+
<input type="text" id="signup-name" placeholder="Enter your name" required>
|
139 |
+
<label for="signup-email">Email</label>
|
140 |
+
<input type="email" id="signup-email" placeholder="Enter your email" required>
|
141 |
+
<label for="signup-password">Password</label>
|
142 |
+
<input type="password" id="signup-password" placeholder="Enter your password" required>
|
143 |
+
<button type="submit">Sign Up</button>
|
144 |
+
</form>
|
145 |
+
</div>
|
146 |
+
</div>
|
147 |
+
|
148 |
+
<script>
|
149 |
+
function switchToSignUp() {
|
150 |
+
document.querySelectorAll('.form-container')[0].style.display = 'none';
|
151 |
+
document.querySelectorAll('.form-container')[1].style.display = 'block';
|
152 |
+
}
|
153 |
+
</script>
|
154 |
+
</body>
|
155 |
+
</html>
|
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
USER user
|
5 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
6 |
+
|
7 |
+
WORKDIR /app
|
8 |
+
|
9 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
11 |
+
|
12 |
+
COPY --chown=user . /app
|
13 |
+
CMD ["gunicorn", "-b","0.0.0.0:7860","app:app"]
|
RRDBNet_arch.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import functools
|
2 |
+
import torch
|
3 |
+
import torch.nn as nn
|
4 |
+
import torch.nn.functional as F
|
5 |
+
|
6 |
+
|
7 |
+
def make_layer(block, n_layers):
|
8 |
+
layers = []
|
9 |
+
for _ in range(n_layers):
|
10 |
+
layers.append(block())
|
11 |
+
return nn.Sequential(*layers)
|
12 |
+
|
13 |
+
|
14 |
+
class ResidualDenseBlock_5C(nn.Module):
|
15 |
+
def __init__(self, nf=64, gc=32, bias=True):
|
16 |
+
super(ResidualDenseBlock_5C, self).__init__()
|
17 |
+
# gc: growth channel, i.e. intermediate channels
|
18 |
+
self.conv1 = nn.Conv2d(nf, gc, 3, 1, 1, bias=bias)
|
19 |
+
self.conv2 = nn.Conv2d(nf + gc, gc, 3, 1, 1, bias=bias)
|
20 |
+
self.conv3 = nn.Conv2d(nf + 2 * gc, gc, 3, 1, 1, bias=bias)
|
21 |
+
self.conv4 = nn.Conv2d(nf + 3 * gc, gc, 3, 1, 1, bias=bias)
|
22 |
+
self.conv5 = nn.Conv2d(nf + 4 * gc, nf, 3, 1, 1, bias=bias)
|
23 |
+
self.lrelu = nn.LeakyReLU(negative_slope=0.2, inplace=True)
|
24 |
+
|
25 |
+
# initialization
|
26 |
+
# mutil.initialize_weights([self.conv1, self.conv2, self.conv3, self.conv4, self.conv5], 0.1)
|
27 |
+
|
28 |
+
def forward(self, x):
|
29 |
+
x1 = self.lrelu(self.conv1(x))
|
30 |
+
x2 = self.lrelu(self.conv2(torch.cat((x, x1), 1)))
|
31 |
+
x3 = self.lrelu(self.conv3(torch.cat((x, x1, x2), 1)))
|
32 |
+
x4 = self.lrelu(self.conv4(torch.cat((x, x1, x2, x3), 1)))
|
33 |
+
x5 = self.conv5(torch.cat((x, x1, x2, x3, x4), 1))
|
34 |
+
return x5 * 0.2 + x
|
35 |
+
|
36 |
+
|
37 |
+
class RRDB(nn.Module):
|
38 |
+
'''Residual in Residual Dense Block'''
|
39 |
+
|
40 |
+
def __init__(self, nf, gc=32):
|
41 |
+
super(RRDB, self).__init__()
|
42 |
+
self.RDB1 = ResidualDenseBlock_5C(nf, gc)
|
43 |
+
self.RDB2 = ResidualDenseBlock_5C(nf, gc)
|
44 |
+
self.RDB3 = ResidualDenseBlock_5C(nf, gc)
|
45 |
+
|
46 |
+
def forward(self, x):
|
47 |
+
out = self.RDB1(x)
|
48 |
+
out = self.RDB2(out)
|
49 |
+
out = self.RDB3(out)
|
50 |
+
return out * 0.2 + x
|
51 |
+
|
52 |
+
|
53 |
+
class RRDBNet(nn.Module):
|
54 |
+
def __init__(self, in_nc, out_nc, nf, nb, gc=32):
|
55 |
+
super(RRDBNet, self).__init__()
|
56 |
+
RRDB_block_f = functools.partial(RRDB, nf=nf, gc=gc)
|
57 |
+
|
58 |
+
self.conv_first = nn.Conv2d(in_nc, nf, 3, 1, 1, bias=True)
|
59 |
+
self.RRDB_trunk = make_layer(RRDB_block_f, nb)
|
60 |
+
self.trunk_conv = nn.Conv2d(nf, nf, 3, 1, 1, bias=True)
|
61 |
+
#### upsampling
|
62 |
+
self.upconv1 = nn.Conv2d(nf, nf, 3, 1, 1, bias=True)
|
63 |
+
self.upconv2 = nn.Conv2d(nf, nf, 3, 1, 1, bias=True)
|
64 |
+
self.HRconv = nn.Conv2d(nf, nf, 3, 1, 1, bias=True)
|
65 |
+
self.conv_last = nn.Conv2d(nf, out_nc, 3, 1, 1, bias=True)
|
66 |
+
|
67 |
+
self.lrelu = nn.LeakyReLU(negative_slope=0.2, inplace=True)
|
68 |
+
|
69 |
+
def forward(self, x):
|
70 |
+
fea = self.conv_first(x)
|
71 |
+
trunk = self.trunk_conv(self.RRDB_trunk(fea))
|
72 |
+
fea = fea + trunk
|
73 |
+
|
74 |
+
fea = self.lrelu(self.upconv1(F.interpolate(fea, scale_factor=2, mode='nearest')))
|
75 |
+
fea = self.lrelu(self.upconv2(F.interpolate(fea, scale_factor=2, mode='nearest')))
|
76 |
+
out = self.conv_last(self.lrelu(self.HRconv(fea)))
|
77 |
+
|
78 |
+
return out
|
app.py
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pickle
|
3 |
+
from flask import Flask, render_template, request, redirect, url_for, flash, send_file
|
4 |
+
from flask_bcrypt import Bcrypt
|
5 |
+
from PIL import Image
|
6 |
+
import numpy as np
|
7 |
+
import cv2
|
8 |
+
import onnxruntime
|
9 |
+
from transformers import BlipProcessor, BlipForConditionalGeneration, BlipForQuestionAnswering
|
10 |
+
from werkzeug.utils import secure_filename
|
11 |
+
import pandas as pd
|
12 |
+
from duckduckgo_search import DDGS
|
13 |
+
|
14 |
+
# Initialize Flask app and Bcrypt for password hashing
|
15 |
+
app = Flask(__name__)
|
16 |
+
app.secret_key = 'your_secret_key'
|
17 |
+
bcrypt = Bcrypt(app)
|
18 |
+
|
19 |
+
# Define paths to your models
|
20 |
+
caption_model_path = "models/trained_model(1).pkl"
|
21 |
+
vqa_model_path = "models/vqa_model.pkl"
|
22 |
+
|
23 |
+
# Set upload folder and allowed extensions
|
24 |
+
app.config['UPLOAD_FOLDER'] = 'static/uploads'
|
25 |
+
app.config['UPSCALED_FOLDER'] = 'static/upscaled'
|
26 |
+
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
27 |
+
os.makedirs(app.config['UPSCALED_FOLDER'], exist_ok=True)
|
28 |
+
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
|
29 |
+
|
30 |
+
# Preload models and processors for efficiency
|
31 |
+
caption_processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
|
32 |
+
caption_model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
|
33 |
+
vqa_processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-capfilt-large")
|
34 |
+
vqa_model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-capfilt-large")
|
35 |
+
|
36 |
+
# Helper functions
|
37 |
+
def allowed_file(filename):
|
38 |
+
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
39 |
+
|
40 |
+
def convert_pil_to_cv2(image):
|
41 |
+
# pil_image = image.convert("RGB")
|
42 |
+
open_cv_image = np.array(image)
|
43 |
+
# RGB to BGR
|
44 |
+
open_cv_image = open_cv_image[:, :, ::-1].copy()
|
45 |
+
return open_cv_image
|
46 |
+
|
47 |
+
|
48 |
+
def pre_process(img: np.array) -> np.array:
|
49 |
+
# H, W, C -> C, H, W
|
50 |
+
img = np.transpose(img[:, :, 0:3], (2, 0, 1))
|
51 |
+
# C, H, W -> 1, C, H, W
|
52 |
+
img = np.expand_dims(img, axis=0).astype(np.float32)
|
53 |
+
return img
|
54 |
+
|
55 |
+
def post_process(img: np.array) -> np.array:
|
56 |
+
# 1, C, H, W -> C, H, W
|
57 |
+
img = np.squeeze(img)
|
58 |
+
# C, H, W -> H, W, C
|
59 |
+
img = np.transpose(img, (1, 2, 0))[:, :, ::-1].astype(np.uint8)
|
60 |
+
return img
|
61 |
+
|
62 |
+
def inference(model_path: str, img_array: np.array) -> np.array:
|
63 |
+
options = onnxruntime.SessionOptions()
|
64 |
+
options.intra_op_num_threads = 1
|
65 |
+
options.inter_op_num_threads = 1
|
66 |
+
ort_session = onnxruntime.InferenceSession(model_path, options)
|
67 |
+
ort_inputs = {ort_session.get_inputs()[0].name: img_array}
|
68 |
+
ort_outs = ort_session.run(None, ort_inputs)
|
69 |
+
|
70 |
+
return ort_outs[0]
|
71 |
+
|
72 |
+
def upscale(image_path: str, model="modelx2"):
|
73 |
+
model_path = f"models/{model}.ort"
|
74 |
+
pil_image = Image.open(image_path)
|
75 |
+
img = convert_pil_to_cv2(pil_image)
|
76 |
+
if img.ndim == 2:
|
77 |
+
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
|
78 |
+
|
79 |
+
if img.shape[2] == 4:
|
80 |
+
alpha = img[:, :, 3] # GRAY
|
81 |
+
alpha = cv2.cvtColor(alpha, cv2.COLOR_GRAY2BGR) # BGR
|
82 |
+
alpha_output = post_process(inference(model_path, pre_process(alpha))) # BGR
|
83 |
+
alpha_output = cv2.cvtColor(alpha_output, cv2.COLOR_BGR2GRAY) # GRAY
|
84 |
+
|
85 |
+
img = img[:, :, 0:3] # BGR
|
86 |
+
image_output = post_process(inference(model_path, pre_process(img))) # BGR
|
87 |
+
image_output = cv2.cvtColor(image_output, cv2.COLOR_BGR2BGRA) # BGRA
|
88 |
+
image_output[:, :, 3] = alpha_output
|
89 |
+
elif img.shape[2] == 3:
|
90 |
+
image_output = post_process(inference(model_path, pre_process(img)))
|
91 |
+
image_output = cv2.cvtColor(image_output, cv2.COLOR_BGR2RGB)
|
92 |
+
return image_output
|
93 |
+
|
94 |
+
# Main route
|
95 |
+
@app.route('/')
|
96 |
+
def index():
|
97 |
+
return render_template('index.html', models=["modelx2", "modelx4"])
|
98 |
+
|
99 |
+
@app.route('/upload', methods=['POST'])
|
100 |
+
def upload_file():
|
101 |
+
if 'file' not in request.files:
|
102 |
+
flash('Please upload an image.')
|
103 |
+
return redirect(url_for('index'))
|
104 |
+
|
105 |
+
file = request.files['file']
|
106 |
+
if file and allowed_file(file.filename):
|
107 |
+
filename = secure_filename(file.filename)
|
108 |
+
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
109 |
+
file.save(filepath)
|
110 |
+
similar_images = []
|
111 |
+
try:
|
112 |
+
upscaled_img = upscale(filepath)
|
113 |
+
upscaled_filename = f"upscaled_{filename}"
|
114 |
+
upscaled_path = os.path.join(app.config['UPSCALED_FOLDER'], upscaled_filename)
|
115 |
+
cv2.imwrite(upscaled_path, upscaled_img)
|
116 |
+
|
117 |
+
image = Image.open(upscaled_path).convert("RGB")
|
118 |
+
caption = generate_caption(image)
|
119 |
+
|
120 |
+
results = DDGS().images(
|
121 |
+
keywords=caption,
|
122 |
+
region="wt-wt",
|
123 |
+
safesearch="off",
|
124 |
+
size=None,
|
125 |
+
color="Monochrome",
|
126 |
+
type_image=None,
|
127 |
+
layout=None,
|
128 |
+
license_image=None,
|
129 |
+
max_results=100,
|
130 |
+
)
|
131 |
+
for i in results:
|
132 |
+
similar_images.append(i['image'])
|
133 |
+
|
134 |
+
|
135 |
+
image_url = url_for('serve_upscaled_file', filename=upscaled_filename)
|
136 |
+
return render_template('index.html',input_image_url=filepath, image_url=upscaled_path ,similar_images=similar_images, show_buttons=True)
|
137 |
+
except Exception as e:
|
138 |
+
flash(f"Upscaling failed: {e}")
|
139 |
+
return redirect(url_for('index'))
|
140 |
+
else:
|
141 |
+
flash('Invalid file format. Please upload a PNG, JPG, or JPEG file.')
|
142 |
+
return redirect(url_for('index'))
|
143 |
+
|
144 |
+
@app.route('/process_image', methods=['POST'])
|
145 |
+
def process_image():
|
146 |
+
image_url = os.path.basename(request.form.get('image_url'))
|
147 |
+
filepath = os.path.join(app.config['UPSCALED_FOLDER'], image_url)
|
148 |
+
|
149 |
+
print(filepath)
|
150 |
+
image = Image.open(filepath).convert("RGB")
|
151 |
+
if os.path.exists(filepath):
|
152 |
+
|
153 |
+
if 'vqa' in request.form:
|
154 |
+
question = request.form.get('question')
|
155 |
+
if question:
|
156 |
+
answer = answer_question(image, question)
|
157 |
+
return render_template('index.html', image_url=filepath, answer=answer, show_buttons=True, question=question)
|
158 |
+
else:
|
159 |
+
flash("Please enter a question.")
|
160 |
+
elif 'caption' in request.form:
|
161 |
+
caption = generate_caption(image)
|
162 |
+
return render_template('index.html', image_url=filepath, caption=caption, show_buttons=True)
|
163 |
+
else:
|
164 |
+
flash("File not found. Please re-upload the image.")
|
165 |
+
return redirect(url_for('index'))
|
166 |
+
|
167 |
+
def generate_caption(image):
|
168 |
+
# Process the image and prepare it for input to the model
|
169 |
+
inputs = caption_processor(images=image, return_tensors="pt")
|
170 |
+
|
171 |
+
# Generate caption (model's output is token IDs)
|
172 |
+
out = caption_model.generate(**inputs)
|
173 |
+
|
174 |
+
# Decode the generated tokens back into text (the output is a tensor of token IDs)
|
175 |
+
caption = caption_processor.decode(out[0], skip_special_tokens=True)
|
176 |
+
|
177 |
+
return caption
|
178 |
+
|
179 |
+
def answer_question(image, question):
|
180 |
+
# Process the image and the question, prepare them for input to the model
|
181 |
+
inputs = vqa_processor(images=image, text=question, return_tensors="pt")
|
182 |
+
|
183 |
+
# Generate an answer (model's output is token IDs)
|
184 |
+
out = vqa_model.generate(**inputs)
|
185 |
+
|
186 |
+
# Decode the generated tokens back into the answer (again, output is token IDs)
|
187 |
+
answer = vqa_processor.decode(out[0], skip_special_tokens=True)
|
188 |
+
|
189 |
+
return answer
|
190 |
+
|
191 |
+
@app.route('/uploads/<filename>')
|
192 |
+
def serve_uploaded_file(filename):
|
193 |
+
return send_file(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
194 |
+
|
195 |
+
@app.route('/upscaled/<filename>')
|
196 |
+
def serve_upscaled_file(filename):
|
197 |
+
return send_file(os.path.join(app.config['UPSCALED_FOLDER'], filename))
|
198 |
+
|
199 |
+
# Run app
|
200 |
+
if __name__ == '__main__':
|
201 |
+
app.run(debug=True)
|
duckduck_images.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
|
duckduck_tutorial.csv
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
title,image,thumbnail,url,height,width,source
|
2 |
+
Butterfly in Black and White | Andreas Klodt | Flickr,https://c2.staticflickr.com/6/5477/11950212626_3f51b5f552_b.jpg,https://tse2.mm.bing.net/th?id=OIP.z1o1SBuzBXkQxQvZ1whnbAHaHa&pid=Api,http://flickr.com/photos/andreas_klodt/11950212626,1024,1024,Bing
|
3 |
+
Monarch Butterfly Flying Sketch,https://cdn4.vectorstock.com/i/1000x1000/05/78/monarch-butterfly-flying-silhouette-high-quality-vector-42890578.jpg,https://tse2.mm.bing.net/th?id=OIP.Z3UOWqSINbHEOTXM4HiKZQHaH_&pid=Api,https://proper-cooking.info/monarch-butterfly-flying-sketch,1080,1000,Bing
|
4 |
+
Elegant Grey Intricate Butterfly Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/220000/velka/elegant-grey-intricate-butterfly-1496112487XHO.jpg,https://tse2.mm.bing.net/th?id=OIP.mPQNfYbdgjCfx2CEBiGm4wHaHa&pid=Api,https://www.publicdomainpictures.net/view-image.php?image=214949&picture=elegant-grey-intricate-butterfly,1920,1920,Bing
|
5 |
+
50 Butterfly Coloring Pages: Free Printable Sheets,https://momlovesbest.com/wp-content/uploads/2023/06/butterfly-coloring-pages-1.webp,https://tse4.mm.bing.net/th?id=OIP.NJFO5VQlsdjEx5RA75ZKrAHaJo&pid=Api,https://momlovesbest.com/butterfly-coloring-pages,1248,960,Bing
|
6 |
+
silueta de mariposa monarca. ilustración vectorial aislado sobre fondo ...,https://static.vecteezy.com/system/resources/previews/011/588/681/original/monarch-butterfly-silhouette-illustration-isolated-on-white-background-vector.jpg,https://tse4.mm.bing.net/th?id=OIP.8IxPfDZO__C7yGP7cIR_vAHaHa&pid=Api,https://es.vecteezy.com/arte-vectorial/11588681-silueta-de-mariposa-monarca-ilustracion-vectorial-aislado-sobre-fondo-blanco,1920,1920,Bing
|
7 |
+
Black Wallpaper: Butterfly,https://2.bp.blogspot.com/-BfFL4MNGwPY/TnxJeTuJiAI/AAAAAAAADig/2VKVfoCMWHg/s1600/butterfly+wallpaper+black.jpg,https://tse3.mm.bing.net/th?id=OIP.4EOmK8p1iqAUfPDra3mZ8gHaFj&pid=Api,https://naturesource.blogspot.com/2011/09/black-wallpaper-butterfly.html,768,1024,Bing
|
8 |
+
"Butterfly black silhouette with flowers, outline Stock Vector Image ...",https://c8.alamy.com/comp/2R6MBCG/butterfly-black-silhouette-with-flowers-outline-2R6MBCG.jpg,https://tse1.mm.bing.net/th?id=OIP.rrrNvYHrpmK20bxkCmSgLgHaH6&pid=Api,https://www.alamy.com/butterfly-black-silhouette-with-flowers-outline-image554867728.html,1390,1300,Bing
|
9 |
+
Premium Vector | Drawing black silhouettes of butterflies on a white ...,https://img.freepik.com/premium-vector/drawing-black-silhouettes-butterflies-white-background_422871-511.jpg?w=2000,https://tse1.mm.bing.net/th?id=OIP.TM2nZeTXOfYGURk8erVLVAHaDt&pid=Api,https://www.freepik.com/premium-vector/drawing-black-silhouettes-butterflies-white-background_40677693.htm,1000,2000,Bing
|
10 |
+
Free 13 Butterfly Drawings In Ai - NBKomputer,https://png.pngtree.com/png-clipart/20230607/original/pngtree-free-line-drawings-of-butterflies-png-image_9181556.png,https://tse2.mm.bing.net/th?id=OIP.ZIQwJ3mEiuMDZATnyU1RKAHaHa&pid=Api,https://nbkomputer.com/free-13-butterfly-drawings-in-ai/,1200,1200,Bing
|
11 |
+
"Free Butterfly Sketch Cliparts, Download Free Butterfly Sketch Cliparts ...",https://clipart-library.com/image_gallery/n200021.png,https://tse1.mm.bing.net/th?id=OIP.j8sFYEJE9HkoOiQIvPVthgHaHa&pid=Api,https://clipart-library.com/butterfly-sketch-cliparts.html,1400,1400,Bing
|
12 |
+
Butterfly Life Cycle Coloring Page - ColoringBay,https://coloringbay.com/wp-content/uploads/butterfly-life-cycle-coloring-page.jpg,https://tse2.mm.bing.net/th?id=OIP.mo_0TgYQZE34Alg1UyIQIwHaFW&pid=Api,https://coloringbay.com/butterfly-coloring-pages/butterfly-life-cycle-coloring-page,1376,1904,Bing
|
13 |
+
"Black butterfly, Butterfly Stencil Silhouette Drawing, macaron ...",https://i.pinimg.com/736x/74/22/86/742286059a4d6d1955d670f23b9ce2ef.jpg,https://tse2.mm.bing.net/th?id=OIP.zq8xdJonQo6aT6tVMdt9ugHaGl&pid=Api,https://www.pinterest.co.kr/pin/black-butterfly-butterfly-stencil-silhouette-drawing-macaron-template-brush-footed-butterfly-png--560205641157656526/,654,736,Bing
|
14 |
+
Monarch Butterflies Png Clipart,https://i.etsystatic.com/22467704/r/il/ea4f3c/3922777498/il_fullxfull.3922777498_jmio.jpg,https://tse3.mm.bing.net/th?id=OIP.X3FwV4Kmi2wUxA5CXedbFwHaGH&pid=Api,https://animalia-life.club/qa/pictures/monarch-butterflies-png-clipart,1960,2376,Bing
|
15 |
+
"Free Butterfly Illustration Black And White, Download Free Butterfly ...",https://clipart-library.com/images/8c65aXdqi.gif,https://tse3.mm.bing.net/th?id=OIP.sDm6SDwWTWAMnE0aLMLJ1QHaGW&pid=Api,https://clipart-library.com/free/butterfly-illustration-black-and-white.html,878,1024,Bing
|
16 |
+
Butterfly Sketch,https://bi.fbcd.co/posts/outline-butterfly-sketch-free-drawing-tutorial-63624369b11d2524454607.jpg,https://tse4.mm.bing.net/th?id=OIP.cy4PsykDd106tvIvJ7LNeQHaFL&pid=Api,https://fity.club/lists/suggestions/butterfly-sketch/,1050,1500,Bing
|
17 |
+
"Butterfly Liner Vector, Butterfly Drawing, Butterfly Sketch, Butterfly ...",https://png.pngtree.com/png-clipart/20230405/original/pngtree-butterfly-liner-png-image_9028153.png,https://tse2.mm.bing.net/th?id=OIP.xDLvOWXsykhg7AdENJRqdAHaHa&pid=Api,https://pngtree.com/freepng/butterfly-liner-vector_9028153.html,1200,1200,Bing
|
18 |
+
"Butterfly Pattern PNG Transparent, Butterfly Pattern, Butterfly Drawing ...",https://png.pngtree.com/png-clipart/20190705/original/pngtree-butterfly-pattern-png-image_4364940.jpg,https://tse3.mm.bing.net/th?id=OIP.Klk-yYjUQUO-dbzXq9jGTgHaHa&pid=Api,https://pngtree.com/freepng/butterfly-pattern_4364940.html,1200,1200,Bing
|
19 |
+
Butterfly Tattoo Clipart Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/60000/velka/butterfly-tattoo-clipart.jpg,https://tse3.mm.bing.net/th?id=OIP.D3iCgEUM6S6hobjoVKMYfwHaHa&pid=Api,https://www.publicdomainpictures.net/view-image.php?image=50565&picture=butterfly-tattoo-clipart,1920,1920,Bing
|
20 |
+
Butterfly Coloring Page Images | Crazy Gallery | Coloriage papillon ...,https://i.pinimg.com/originals/4d/1d/93/4d1d93767dfb69b3894f73523144d3a8.jpg,https://tse3.mm.bing.net/th?id=OIP.laK2IyXqpFlcV7cuSDgjQQHaJl&pid=Api,https://in.pinterest.com/pin/560627853598147196/,3300,2550,Bing
|
21 |
+
"Free Black And White Butterfly, Download Free Black And White Butterfly ...",https://clipart-library.com/images/pcq84X8Ei.gif,https://tse2.mm.bing.net/th?id=OIP.-UnMQkXUh_qVWXd5j8J55AHaFS&pid=Api,https://clipart-library.com/black-and-white-butterfly.html,731,1023,Bing
|
22 |
+
"Free Butterfly Wing Outline, Download Free Butterfly Wing Outline png ...",https://clipart-library.com/images/AibjGBXbT.gif,https://tse3.mm.bing.net/th?id=OIP.7Z8sgoltGA3dOQYA1KGQdQHaG6&pid=Api,https://clipart-library.com/butterfly-wing-outline.html,956,1024,Bing
|
23 |
+
butterfly clipart black and white - Clip Art Library,https://clipart-library.com/new_gallery/butterfly-clipart-73.png,https://tse4.mm.bing.net/th?id=OIP.r4sDgFOuntDouC2DSpLZwAHaHp&pid=Api,https://clipart-library.com/clipart/butterfly-clipart-73.htm,2045,1979,Bing
|
24 |
+
Butterfly Coloring Pages | Team colors,https://1.bp.blogspot.com/-eY_UWp-XnTY/UYk_hHKeFxI/AAAAAAAAE8A/3Q0uWLsSrgs/s1600/monarch-butterfly-coloring-pages.jpg,https://tse2.mm.bing.net/th?id=OIP.NeT-B8RfHY7AuVeVAeynSwHaG5&pid=Api,https://teamcolors.blogspot.com/2013/05/butterfly-coloring-pages.html,932,1000,Bing
|
25 |
+
"Free Black And White Butterfly, Download Free Black And White Butterfly ...",http://clipart-library.com/images/yikKKk4BT.png,https://tse2.mm.bing.net/th?id=OIP.mIVpg7BhJa18Sq0INCSeiAHaG5&pid=Api,http://clipart-library.com/black-and-white-butterfly.html,2381,2555,Bing
|
26 |
+
50 Butterfly Coloring Pages: Free Printable Sheets,https://momlovesbest.com/wp-content/uploads/2023/06/butterfly-coloring-pages-2.webp,https://tse2.mm.bing.net/th?id=OIP.QTAMgTGf2dUrdiNYX9vPWwHaJo&pid=Api,https://momlovesbest.com/butterfly-coloring-pages,1248,960,Bing
|
27 |
+
Clipart - Black And White Butterfly,https://openclipart.org/image/2400px/svg_to_png/222362/Black-And-White-Butterfly.png,https://tse4.mm.bing.net/th?id=OIP.N2uarFW2feBtdmCg0ujxbgHaFe&pid=Api,https://openclipart.org/detail/222362/black-and-white-butterfly,1757,2374,Bing
|
28 |
+
Butterfly Silhouette Sticker - Free PNG Image,https://i.pinimg.com/736x/58/e0/40/58e0402a12f84e45640a261ea021f138.jpg,https://tse2.mm.bing.net/th?id=OIP.Y8JvaW12YzisRqqPm_pB-gHaHa&pid=Api,https://www.pinterest.com/pin/butterfly-silhouette-sticker-free-png-image--293508100729864822/,736,736,Bing
|
29 |
+
cigarette cards butterflies - Clip Art Library,https://clipart-library.com/img/1714017.png,https://tse2.mm.bing.net/th?id=OIP.rVWwbEJR9o2cJ6sRsjOamgHaHZ&pid=Api,https://clipart-library.com/clipart/1714017.htm,1418,1420,Bing
|
30 |
+
"Butterfly. Clipart Transparent PNG Hd, Vector Butterfly Icon, Butterfly ...",https://png.pngtree.com/png-clipart/20190924/original/pngtree-vector-butterfly-icon-png-image_4868975.jpg,https://tse4.mm.bing.net/th?id=OIP.uHJggCKDUeiKflsotKf9owHaHa&pid=Api,https://pngtree.com/freepng/vector-butterfly-icon_4868975.html,1200,1200,Bing
|
31 |
+
Butterfly Coloring Pages,http://www.butterfly-gardens.com/coloring-pages/butterfly-14-coloring-page.jpg,https://tse4.mm.bing.net/th?id=OIP.itrOkpDA-SzylTGQ403nwgHaJl&pid=Api,http://www.butterfly-gardens.com/butterfly-articles/butterfly-coloring-pages.php,3300,2550,Bing
|
32 |
+
Butterfly Silhouette Clipart Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/270000/velka/butterfly-silhouette-clipart-1533967469I4o.jpg,https://tse2.mm.bing.net/th?id=OIP.PG5gl7I5otrH-1XSBV9x-gHaHa&pid=Api,https://www.publicdomainpictures.net/en/view-image.php?image=264451&picture=butterfly-silhouette-clipart,1920,1920,Bing
|
33 |
+
butterfly silhouette png - Clip Art Library,https://clipart-library.com/img/1077930.png,https://tse1.mm.bing.net/th?id=OIP.y-Yx6bTH-OTx81uQcYAyHQHaGM&pid=Api,https://clipart-library.com/clipart/1077930.htm,1946,2326,Bing
|
34 |
+
Butterfly Hard Coloring Page || COLORING-PAGES-PRINTABLE.COM,https://coloring-pages-printable.com/wp-content/uploads/Adults/Butterflies/butterfly-coloring-pages-for-adults-25.GIF,https://tse2.mm.bing.net/th?id=OIP.dAatYRi20YnOSV50Z-L3HAHaId&pid=Api,https://coloring-pages-printable.com/print/adult-butterflies/butterfly-coloring-pages-for-adults.php?id=25,1023,895,Bing
|
35 |
+
Butterfly Coloring Pages|free printable butterfly coloring pages ...,https://4.bp.blogspot.com/_61hf6pzN8OM/SwHiesQeqiI/AAAAAAAAAa8/LKJjVMYg3-k/s1600/butterfly-coloring-pages.gif,https://tse1.mm.bing.net/th?id=OIP.jipJkNey6Wp25-a2cHuIhgHaJ3&pid=Api,https://butterflycoloringpages.blogspot.com/,957,718,Bing
|
36 |
+
Coloring Butterfly Pages,https://mondaymandala.com/wp-content/uploads/Monarch-Butterfly-Hovering-On-Grass-791x1024.jpg,https://tse3.mm.bing.net/th?id=OIP.wRHx6bkQYF5wzx103PxmeQHaJl&pid=Api,https://animalia-life.club/qa/pictures/coloring-butterfly-pages,1024,791,Bing
|
37 |
+
clipart coloring pages butterfly - Clip Art Library,https://clipart-library.com/newimages/butterfly-clip-art-27.gif,https://tse1.mm.bing.net/th?id=OIP.0zVte1GfofIni4-teuZn2wHaIv&pid=Api,https://clipart-library.com/clipart/butterfly-clip-art-27.htm,1416,1200,Bing
|
38 |
+
Adorable Butterfly Coloring Page - Free Printable Coloring Pages for Kids,https://coloringonly.com/images/imgcolor/Adorable-Butterfly-coloring-page.jpg,https://tse2.mm.bing.net/th?id=OIP.JHDFaJhfhwfJrwxCvz0_swHaJS&pid=Api,https://coloringonly.com/pages/adorable-butterfly-coloring-page/,979,780,Bing
|
39 |
+
butterfly template free printable butterfly outlines one little project ...,https://templatelab.com/wp-content/uploads/2019/06/butterfly-template-24.jpg,https://tse2.mm.bing.net/th?id=OIP.flOeAvSATqBd-DmjJNE1SQHaJl&pid=Api,https://munozjanie.blogspot.com/2022/04/butterfly-template-free-printable.html,2500,1932,Bing
|
40 |
+
Rainbow Butterfly Coloring Page | Easy Drawing Guides,https://easydrawingguides.com/wp-content/uploads/2023/01/1410-easy-rainbow-butterfly-coloring-page.png,https://tse1.mm.bing.net/th?id=OIP._BKjT0PXHjif76Nj2UycxgHaHa&pid=Api,https://easydrawingguides.com/coloring-pages/rainbow-butterfly/,680,680,Bing
|
41 |
+
Butterfly silhouette. Silhouette of a moth Stock Vector | Adobe Stock,https://as2.ftcdn.net/v2/jpg/05/36/65/49/1000_F_536654948_cUxoEAyTkbJQZC18gaojandp2isfmkhN.jpg,https://tse2.mm.bing.net/th?id=OIP.N9bbXCjtg58yQZjG5glPKgAAAA&pid=Api,https://stock.adobe.com/images/butterfly-silhouette-silhouette-of-a-moth/536654948,474,474,Bing
|
42 |
+
Butterfly Printable Template | Free Printable Papercraft Templates,https://www.supercoloring.com/sites/default/files/fif/2022/11/butterfly-template-printable-paper-crafts_1.png,https://tse3.mm.bing.net/th?id=OIP.YHnMeHJoYXsP-JRXVYe8rgHaFw&pid=Api,https://www.supercoloring.com/paper-crafts/butterfly-printable-template-1,1165,1500,Bing
|
43 |
+
Pretty and simple butterfly to color - Butterflie Coloring Pages for Kids,https://www.justcolor.net/kids/wp-content/uploads/sites/12/nggallery/butterflies/coloring-pages-for-children-butterflies-99444.jpg,https://tse3.mm.bing.net/th?id=OIP.GfB3mT5VN94tzSkRk3zjuAHaFP&pid=Api,https://www.justcolor.net/kids/coloring-pages-of-animals/butterflies/?image=butterflies__coloring-pages-for-children-butterflies-99444__1,2000,2828,Bing
|
44 |
+
Butterfly wall decor 🦋 💖 Transform your room into a serene sanctuary!,https://mamasmusthaves.com/wp-content/uploads/2023/02/butterfly-wall-decor.png,https://tse3.mm.bing.net/th?id=OIP.XTzXWLEpBBgYoGTTNokxUgHaFS&pid=Api,https://mamasmusthaves.com/butterfly-wall-decor/,1000,1400,Bing
|
45 |
+
Butterfly Silhouette PNG Images & Picture Free Download - Lovepik,https://img.lovepik.com/element/40169/3141.png_1200.png,https://tse2.mm.bing.net/th?id=OIP.-tKTMQyovC_xHTbE4naiRgHaE9&pid=Api,https://lovepik.com/image-401693141/butterfly-silhouette.html,2020,3020,Bing
|
46 |
+
Butterfly Line Drawing: A Step-by-Step Guide - Improve Drawing,https://improvedrawing.com/wp-content/uploads/2022/10/Butterfly-Line-Drawing.jpg,https://tse4.mm.bing.net/th?id=OIP.xDZA6YsjYrrR5D7WBwqKZAHaE8&pid=Api,https://improvedrawing.com/butterfly-line-drawing-a-step-by-step-guide/,800,1200,Bing
|
47 |
+
Simple butterfly black and white outline vector SVG line art Stock ...,https://as1.ftcdn.net/v2/jpg/05/32/29/72/1000_F_532297226_RLOIy04pUPxA3DZYQA77x9botr2X9SHh.jpg,https://tse1.mm.bing.net/th?id=OIP.ew6-Vb5FThAEpLC5WFCFRQHaHf&pid=Api,https://stock.adobe.com/images/simple-butterfly-black-and-white-outline-vector-svg-line-art/532297226,1000,989,Bing
|
48 |
+
Free simple butterflies coloring pages,http://www.bestcoloringpagesforkids.com/wp-content/uploads/2013/07/Monarch-Butterfly-Coloring-Page.jpg,https://tse2.mm.bing.net/th?id=OIP.ObyVQy8EexjINFfYqxizDAHaJ3&pid=Api,http://freecoloringpages.co.uk/?r=simple+butterflies,1266,950,Bing
|
49 |
+
Butterfly Drawing {6 Easy Steps}! - The Graphics Fairy,https://thegraphicsfairy.com/wp-content/uploads/2022/10/Butterfly-Drawing-Lesson-Step2-GraphicsFairy.jpeg,https://tse1.mm.bing.net/th?id=OIP.oLBgKTjsNd2njT6zf5BfHAHaGn&pid=Api,https://thegraphicsfairy.com/butterfly-drawing/,1340,1500,Bing
|
50 |
+
Printable Butterfly Outline Templates,https://colormadehappy.com/wp-content/uploads/2022/09/Butterfly-Outline-4.jpg,https://tse4.mm.bing.net/th?id=OIP.rPypw7Rs5KKOwo9mNKub1QHaJl&pid=Api,https://colormadehappy.com/printable-butterfly-outline-templates/,792,612,Bing
|
51 |
+
Monarch butterfly silhouette side view isolated Vector Image,https://cdn5.vectorstock.com/i/1000x1000/17/79/monarch-butterfly-silhouette-side-view-isolated-vector-46331779.jpg,https://tse3.mm.bing.net/th?id=OIP.DmlyqLHBROOjcxX3Rh79jgAAAA&pid=Api,https://www.vectorstock.com/royalty-free-vector/monarch-butterfly-silhouette-side-view-isolated-vector-46331779,511,474,Bing
|
52 |
+
"Hand Embroidery Art, Beaded Embroidery, Embroidery Stitches, Embroidery ...",https://i.pinimg.com/originals/a6/3f/e3/a63fe3328085165e36676b24aade934c.jpg,https://tse4.mm.bing.net/th?id=OIP.fXLcChXUpTFvGK7zUbt1YgHaKe&pid=Api,https://www.pinterest.com/pin/539446861628866950/,3508,2480,Bing
|
53 |
+
White Butterfly Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/200000/velka/white-butterfly-1477850043iTW.jpg,https://tse3.mm.bing.net/th?id=OIP.zt5SBfh7J_nSrAlj5dYNegHaHa&pid=Api,https://www.publicdomainpictures.net/en/view-image.php?image=197111&picture=white-butterfly,1920,1920,Bing
|
54 |
+
SVG > insect beautiful spring summer - Free SVG Image & Icon. | SVG Silh,https://svgsilh.com/svg/306898.svg,https://tse1.mm.bing.net/th?id=OIP.fUCuM6I6q6irIgtfNL56VQHaG5&pid=Api,https://svgsilh.com/image/306898.html,1192,1280,Bing
|
55 |
+
Pin by Alexus Ledesma on Tattoos that I love in 2021 | Butterfly ...,https://i.pinimg.com/originals/cb/9b/1e/cb9b1eb02b55678c21b5437c609f3e20.jpg,https://tse4.mm.bing.net/th?id=OIP.ybLsPUqYye034JFknbsCWQHaF7&pid=Api,https://www.pinterest.com/pin/355925176808463485/,2179,2719,Bing
|
56 |
+
free printable butterfly coloring pages for kids - free printable ...,http://www.bestcoloringpagesforkids.com/wp-content/uploads/2013/07/Kids-Butterfly-Coloring-Pages.jpg,https://tse4.mm.bing.net/th?id=OIP.j-okC2YXJYT_0PmPmu1UGgHaHp&pid=Api,https://jeremykeyer.blogspot.com/2024/01/free-printable-butterfly-coloring-pages.html,2045,1979,Bing
|
57 |
+
Printable Butterfly Silhouette Template - TemplatesArea,https://www.templatesarea.com/wp-content/uploads/2022/12/printable-butterfly-silhouette-template.jpg,https://tse3.mm.bing.net/th?id=OIP.FvYI_ps7Zom_sFffUJhmagHaLH&pid=Api,https://www.templatesarea.com/printable-butterfly-silhouette-template/,900,600,Bing
|
58 |
+
Butterfly Drawing {6 Easy Steps}! - The Graphics Fairy,https://thegraphicsfairy.com/wp-content/uploads/2022/10/Butterfly-Drawing-Lesson-Step3-GraphicsFairy.jpeg,https://tse2.mm.bing.net/th?id=OIP.RIw1liZj-sMzcEVim90XLgHaGn&pid=Api,https://thegraphicsfairy.com/butterfly-drawing/,1340,1500,Bing
|
59 |
+
Arriba 77+ mariposa dibujo realista última - camera.edu.vn,https://images.vexels.com/content/126014/preview/realistic-butterfly-illustration-set-fd34bc.png,https://tse2.mm.bing.net/th?id=OIP.kG266gkDG77pkfF4ySx4pAHaHa&pid=Api,https://camera.edu.vn/mariposa-dibujo-realista-ktv5j8vi/,1500,1500,Bing
|
60 |
+
Butterfly Tattoo Clipart Free Stock Photo - Public Domain Pictures,http://publicdomainpictures.net/pictures/60000/velka/butterfly-tattoo-clipart.jpg,https://tse2.mm.bing.net/th?id=OIP.tCbn-sm-Ol2JhV4Ly3tu7AHaHa&pid=Api,http://publicdomainpictures.net/view-image.php?image=50565&picture=butterfly-tattoo-clipart,1920,1920,Bing
|
61 |
+
"Free Butterfly Tattoo Designs PNG Transparent Images, Download Free ...",https://clipart-library.com/image_gallery2/Butterfly-Tattoo-Designs-PNG-Picture.png,https://tse3.mm.bing.net/th?id=OIP.Bgkuf_YZz4IZ_yaZPtF3BgHaIG&pid=Api,https://clipart-library.com/butterfly-tattoo-designs-png.html,1121,1024,Bing
|
62 |
+
"Butterfly png doodle sticker, black | Free PNG Illustration - rawpixel ...",https://i.pngimg.me/thumb/f/720/comrawpixel6551866.jpg,https://tse4.mm.bing.net/th?id=OIP.7G71zIUuQUbcomLBNHzE-gHaHa&pid=Api,https://png.is/f/butterfly-png-doodle-sticker-black-free-png-illustration-rawpixel/comrawpixel6551866-202205241719.html,720,720,Bing
|
63 |
+
Butterfly Outline | ClipArt ETC,http://etc.usf.edu/clipart/26200/26287/butterfly_26287.tif,https://tse1.mm.bing.net/th?id=OIP.FByJNj_0DdGLJ6cbu0TnRwHaG6&pid=Api,http://etc.usf.edu/clipart/26200/26287/butterfly_26287.htm,2241,2400,Bing
|
64 |
+
Butterfly Tracing Coloring Page - Free Printable Coloring Pages for Kids,https://coloringonly.com/images/imgcolor/Butterfly-Tracing-coloring-page.jpg,https://tse4.mm.bing.net/th?id=OIP.oVmymZCuB_GqPngTllF1sQHaIH&pid=Api,https://coloringonly.com/pages/butterfly-tracing-coloring-page/,876,800,Bing
|
65 |
+
Hand drawn doodle butterfly. Vector simple butterfly clip art. Outline ...,https://static.vecteezy.com/system/resources/previews/009/297/980/original/hand-drawn-doodle-butterfly-simple-butterfly-clip-art-outline-vector.jpg,https://tse2.mm.bing.net/th?id=OIP.dSMFyE4IufXJtep-mlLupAHaHa&pid=Api,https://www.vecteezy.com/vector-art/9297980-hand-drawn-doodle-butterfly-vector-simple-butterfly-clip-art-outline,1920,1920,Bing
|
66 |
+
"Free Butterfly Clipart Black And White, Download Free Butterfly Clipart ...",https://clipart-library.com/2018/butterfly-clipart-black-and-white-9.jpg,https://tse2.mm.bing.net/th?id=OIP.AAC4StgxMaR9yvX_MFwfhwHaHa&pid=Api,https://clipart-library.com/butterfly-clipart-black-and-white.html,1000,1000,Bing
|
67 |
+
"இڿڰۣ-ڰۣ— Dungeons E Dragons, Aquarell Tattoos, Morpho Butterfly ...",https://i.pinimg.com/736x/02/be/dc/02bedce73ecc127e3d8e78837382ed94--butterfly-tattoos-cousin.jpg,https://tse3.mm.bing.net/th?id=OIP.XGfpvIw9j3HdfshAX-0i6QHaHo&pid=Api,https://www.pinterest.com/pin/51017408265113803/,759,736,Bing
|
68 |
+
"Shapes clipart butterfly, Picture #2025233 shapes clipart butterfly",https://webstockreview.net/images/shapes-clipart-butterfly-3.png,https://tse2.mm.bing.net/th?id=OIP.WvNLXI_kWpajsnp-s4LNnQHaFv&pid=Api,https://webstockreview.net/image/shapes-clipart-butterfly/2025233.html,760,980,Bing
|
69 |
+
Amazing Butterfly Coloring Page - Free Printable Coloring Pages for Kids,https://coloringonly.com/images/imgcolor/Amazing-Butterfly-coloring-page.jpg,https://tse1.mm.bing.net/th?id=OIP.j9ZgzdsY1GA8WApHtxsCjwHaFg&pid=Api,https://coloringonly.com/pages/amazing-butterfly-coloring-page/,718,965,Bing
|
70 |
+
Mariposa Stencil,https://cdn.shopify.com/s/files/1/2374/3709/products/Butterfly_Thumb_1800x.png?v=1544577511,https://tse3.mm.bing.net/th?id=OIP.pa6bJuuDBUDYawFtG_C_dgHaF7&pid=Api,https://mungfali.com/explore/Mariposa-Stencil,1440,1800,Bing
|
71 |
+
"Free Butterfly Outline Clipart, Download Free Butterfly Outline Clipart ...",https://clipart-library.com/images/BTaK4nGkc.png,https://tse4.mm.bing.net/th?id=OIP.j4smEXuiuIa0LgDSCbSv2QHaGl&pid=Api,https://clipart-library.com/butterfly-outline-clipart.html,1759,1979,Bing
|
72 |
+
Butterfly Outline Clipart Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/60000/velka/butterfly-outline-clipart.jpg,https://tse2.mm.bing.net/th?id=OIP.0-lYc_K0z4XM3Ra_4WyafgHaHa&pid=Api,https://www.publicdomainpictures.net/view-image.php?image=50564&picture=butterfly-outline-clipart,1920,1920,Bing
|
73 |
+
Butterfly Coloring Pages - 10 Exquisite Illustrations,https://littlesproutlearning.com/wp-content/uploads/2022/03/Coloring-Page-Butterfly-10-scaled.jpg,https://tse3.mm.bing.net/th?id=OIP.kjnxlO52rrk32-mUgoC7ngHaJl&pid=Api,https://littlesproutlearning.com/butterfly-coloring-pages/,2560,1978,Bing
|
74 |
+
butterfly black and white 24134738 PNG,https://static.vecteezy.com/system/resources/previews/024/134/738/non_2x/butterfly-black-and-white-free-png.png,https://tse4.mm.bing.net/th?id=OIP.4id5rVe_Bs-MSQDFL8xQjwHaHa&pid=Api,https://www.vecteezy.com/png/24134738-butterfly-black-and-white,980,980,Bing
|
75 |
+
Butterfly Cut Out Template,https://superstarworksheets.com/wp-content/uploads/2023/02/ButterflyTemplate4Printable.jpg,https://tse3.mm.bing.net/th?id=OIP.X1cGoVxBvqarH9jROpv66gHaFt&pid=Api,https://animalia-life.club/qa/pictures/butterfly-cut-out-template,386,500,Bing
|
76 |
+
butterfly template free printable butterfly outlines one little project ...,https://flyclipart.com/thumb2/printable-butterfly-outline-coloring-pages-pattern-590337.png,https://tse4.mm.bing.net/th?id=OIP.Y6wc8Owg_Q5ZYOTAmQSiDwHaHa&pid=Api,https://caydentanner.blogspot.com/2022/04/butterfly-template-free-printable.html,840,840,Bing
|
77 |
+
Cute Butterfly Coloring Pages For Adults || COLORING-PAGES-PRINTABLE.COM,https://coloring-pages-printable.com/wp-content/uploads/Adults/Butterflies/butterfly-coloring-pages-for-adults-7.GIF,https://tse4.mm.bing.net/th?id=OIP.v-AYdGLTXeEa02FfFbUySAHaHa&pid=Api,https://coloring-pages-printable.com/print/adult-butterflies/butterfly-coloring-pages-for-adults.php?id=7,895,895,Bing
|
78 |
+
"Cute Butterfly, Butterfly Frame, Silhouette Png, Black Silhouette ...",https://i.pinimg.com/originals/d4/b9/5b/d4b95b348fd1236d3a599efc53fc39e9.jpg,https://tse2.mm.bing.net/th?id=OIP.OPB3HdrcZU-zzM9ZHJQhlQHaHa&pid=Api,https://www.pinterest.co.uk/pin/download-premium-png-of-butterfly-frame-png-element-transparent-background-by-benjamas-about-butterfly-silhouette-s-in-2023--986569862102331268/,1000,1000,Bing
|
79 |
+
coloring pages of butterflies - Clip Art Library,https://clipart-library.com/images/pc7rz7oc9.gif,https://tse1.mm.bing.net/th?id=OIP.ceIBFO5_nO4EzmuGVdKlbQHaFL&pid=Api,https://clipart-library.com/clipart/pc7rz7oc9.htm,600,858,Bing
|
80 |
+
[400+] Butterfly Aesthetic Wallpapers | Wallpapers.com,https://wallpapers.com/images/hd/butterfly-aesthetic-black-art-r9pb0g9y9o9olh3s.jpg,https://tse4.mm.bing.net/th?id=OIP.PKSwmv7FXNdOv9scfyz7ZAHaEK&pid=Api,https://wallpapers.com/butterfly-aesthetic,1080,1920,Bing
|
81 |
+
Download Simple Black Butterfly With White Outline Wallpaper ...,https://wallpapers.com/images/hd/simple-black-butterfly-with-white-outline-opaoz30pvtudx19s.jpg,https://tse1.mm.bing.net/th?id=OIP.WVmCrOUszETMe8TkxdWl3AHaMs&pid=Api,https://wallpapers.com/wallpapers/simple-black-butterfly-with-white-outline-opaoz30pvtudx19s.html,1262,736,Bing
|
82 |
+
Line Drawings Of Butterflies - ClipArt Best,http://www.clipartbest.com/cliparts/acq/edk/acqedkdji.png,https://tse1.mm.bing.net/th?id=OIP.BF7K_HEAbwCc4PpKerBoWQHaKe&pid=Api,http://www.clipartbest.com/line-drawings-of-butterflies,2785,1969,Bing
|
83 |
+
Half Butterfly Half Flower SVG | Master Bundles,https://masterbundles.com/wp-content/uploads/edd/2022/09/01.-half-butterfly-half-flower-svg-bundle-1000-x-1500.png,https://tse2.mm.bing.net/th?id=OIP.qb4hMg-cxpUKLReYFZY-ygHaLE&pid=Api,https://masterbundles.com/designstudio/half-butterfly-half-flower-svg/,1495,1000,Bing
|
84 |
+
Download Black Butterfly In Dark Backdrop Wallpaper | Wallpapers.com,https://wallpapers.com/images/hd/black-butterfly-in-dark-backdrop-indhfvebfif2c79c.jpg,https://tse3.mm.bing.net/th?id=OIP.Kab_NZVnjPc69DEVtnwyZgHaNL&pid=Api,https://wallpapers.com/wallpapers/black-butterfly-in-dark-backdrop-indhfvebfif2c79c.html,1309,736,Bing
|
85 |
+
the butterfly life cycle is shown in black and white,https://i.pinimg.com/736x/ff/f1/15/fff115561a33d0356b91124cf59492bc.jpg,https://tse3.mm.bing.net/th?id=OIP.Kr0PBCalX9oGcpL13hVoHQHaKe&pid=Api,https://www.pinterest.de/pin/printable-butterfly-coloring-pages-for-kids-in-2022--492299803031786737/,1024,724,Bing
|
86 |
+
Mono patterns hi-res stock photography and images - Alamy,https://c8.alamy.com/comp/S086Y2/butterfly-S086Y2.jpg,https://tse4.mm.bing.net/th?id=OIP.Qh2KTUgpmJ7f7WADQdWuQgHaJ8&pid=Api,https://www.alamy.com/stock-photo/mono-patterns.html,1390,1035,Bing
|
87 |
+
"Illustration Butterfly Art Logo Tattoo Vector, Butterfly, Butterfly ...",https://png.pngtree.com/png-clipart/20230509/original/pngtree-illustration-butterfly-art-logo-tattoo-png-image_9153704.png,https://tse3.mm.bing.net/th?id=OIP.m14g8zdp6SNpBSqWtue9kAHaHa&pid=Api,https://pngtree.com/freepng/illustration-butterfly-art-logo-tattoo-vector_9153704.html,1200,1200,Bing
|
88 |
+
Butterfly Clipart-black outline butterfly coloring page with dots and ...,https://classroomclipart.com/image/static7/preview2/black-outline-butterfly-coloring-page-with-dots-and-dots-on-the--57299.jpg,https://tse2.mm.bing.net/th?id=OIP.aWlojzV7b_jzKs_W8UisVAHaGD&pid=Api,https://classroomclipart.com/image/vector-clipart/black-outline-butterfly-coloring-page-with-dots-and-dots-on-the-57299.htm,450,550,Bing
|
89 |
+
monarch butterfly tattoo black and white - Natashia Hand,https://i.pinimg.com/originals/05/b3/4c/05b34c5fb27832cc935c075bba19995a.jpg,https://tse4.mm.bing.net/th?id=OIP.y86rdRAhaZMp_JUQGIPsLgHaHa&pid=Api,https://natashiahand.blogspot.com/2022/09/monarch-butterfly-tattoo-black-and-white.html,556,556,Bing
|
90 |
+
Butterfly Cut Out Template,https://superstarworksheets.com/wp-content/uploads/2023/02/ButterflyTemplate1Printable.jpg,https://tse2.mm.bing.net/th?id=OIP.35lVXROYBXmgSU9c7GE4tgHaFt&pid=Api,https://animalia-life.club/qa/pictures/butterfly-cut-out-template,386,500,Bing
|
91 |
+
clipart of flies cartoon black and white - Clip Art Library,https://clipart-library.com/img/924640.png,https://tse3.mm.bing.net/th?id=OIP.4fW8kuaEgzExLQky7TrYCQHaGh&pid=Api,https://clipart-library.com/clipart/924640.htm,6090,6910,Bing
|
92 |
+
Download Elegant Black Butterfly Shining Plain White Wallpaper ...,https://wallpapers.com/images/hd/elegant-black-butterfly-shining-plain-white-2wueee7jcvtw6cpo.jpg,https://tse4.mm.bing.net/th?id=OIP.nJcE1OhVQDlPu3DlC5az5wHaNL&pid=Api,https://wallpapers.com/wallpapers/elegant-black-butterfly-shining-plain-white-2wueee7jcvtw6cpo.html,1272,715,Bing
|
93 |
+
White Butterfly Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/150000/velka/white-butterfly-1451166596DJ7.jpg,https://tse4.mm.bing.net/th?id=OIP.-DahBIlAt2R6GlY0KDHUZQHaHa&pid=Api,https://www.publicdomainpictures.net/en/view-image.php?image=142497&picture=white-butterfly,1920,1920,Bing
|
94 |
+
"Real Butterfly, Yellow Butterfly, Pink Butterfly, Butterfly Wings ...",https://icon-library.com/images/2018/11194388_butterfly-silhouette-portable-network-graphics-png-download.png,https://tse4.mm.bing.net/th?id=OIP.kqpxE5Ql4OLeofNumrRKlwHaKO&pid=Api,https://icon-library.com/png/1094120.html,1216,880,Bing
|
95 |
+
"""Unbelievable Compilation of Butterfly Drawing Images in Full 4K ...",https://c8.alamy.com/comp/PMKKAG/butterfly-line-drawing-isolated-on-a-white-background-vector-illustration-eps10-PMKKAG.jpg,https://tse2.mm.bing.net/th?id=OIP.KeMhK0gUzGBGEQvp5tUpUAHaH6&pid=Api,https://lassho.edu.vn/unbelievable-compilation-of-butterfly-drawing-images-in-full-4k-resolution-over-999-captivating-options/,1390,1300,Bing
|
96 |
+
Fauna Cut Out Stock Images & Pictures - Alamy,https://c8.alamy.com/comp/2CCER0X/butterfly-x-ray-2CCER0X.jpg,https://tse4.mm.bing.net/th?id=OIP.yKemdZa-ij07qn_ucJmGKQHaH6&pid=Api,https://www.alamy.com/stock-photo/fauna.html?cutout=1&sortBy=relevant,1390,1300,Bing
|
97 |
+
Butterfly Outline Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/130000/velka/butterfly-outline.jpg,https://tse4.mm.bing.net/th?id=OIP.hqrLI-eOyCCqvWBuczjwZgHaHj&pid=Api,https://www.publicdomainpictures.net/en/view-image.php?image=125945&picture=butterfly-outline,1920,1881,Bing
|
98 |
+
Butterfly Clipart Free Stock Photo - Public Domain Pictures,https://www.publicdomainpictures.net/pictures/100000/velka/butterfly-clipart.jpg,https://tse1.mm.bing.net/th?id=OIP.yWkHUv8h-n_9AirYkllEgAHaHa&pid=Api,https://www.publicdomainpictures.net/en/view-image.php?image=95313&picture=butterfly-clipart,1920,1920,Bing
|
99 |
+
Stock manipulation hi-res stock photography and images - Alamy,https://c8.alamy.com/comp/2A86GFH/abstract-butterfly-2A86GFH.jpg,https://tse4.mm.bing.net/th?id=OIP.GYIFdIKZexOjutcO2i1d4wHaFc&pid=Api,https://www.alamy.com/stock-photo/stock-manipulation.html,956,1300,Bing
|
100 |
+
How to Draw a Butterfly | Design School,https://bi.fbcd.co/posts/outline-butterfly-wing-details-sketch-easy-tutorial-drawing-6362438ce7afd116188613.jpg,https://tse3.mm.bing.net/th?id=OIP.p5GhBz3lNp9ANJqfc4kAdgAAAA&pid=Api,https://designbundles.net/design-school/how-to-draw-a-butterfly,331,474,Bing
|
101 |
+
Butterflies And Flower Coloring Pages,https://momlovesbest.com/wp-content/uploads/2023/06/butterfly-coloring-pages-5.webp,https://tse1.mm.bing.net/th?id=OIP.GlL2hR_ihI620hsuRK6lBQHaJo&pid=Api,https://animalia-life.club/qa/pictures/butterflies-and-flower-coloring-pages,1248,960,Bing
|
net_interp.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import torch
|
3 |
+
from collections import OrderedDict
|
4 |
+
|
5 |
+
alpha = float(sys.argv[1])
|
6 |
+
|
7 |
+
net_PSNR_path = './models/RRDB_PSNR_x4.pth'
|
8 |
+
net_ESRGAN_path = './models/RRDB_ESRGAN_x4.pth'
|
9 |
+
net_interp_path = './models/interp_{:02d}.pth'.format(int(alpha*10))
|
10 |
+
|
11 |
+
net_PSNR = torch.load(net_PSNR_path)
|
12 |
+
net_ESRGAN = torch.load(net_ESRGAN_path)
|
13 |
+
net_interp = OrderedDict()
|
14 |
+
|
15 |
+
print('Interpolating with alpha = ', alpha)
|
16 |
+
|
17 |
+
for k, v_PSNR in net_PSNR.items():
|
18 |
+
v_ESRGAN = net_ESRGAN[k]
|
19 |
+
net_interp[k] = (1 - alpha) * v_PSNR + alpha * v_ESRGAN
|
20 |
+
|
21 |
+
torch.save(net_interp, net_interp_path)
|
requirements.txt
ADDED
Binary file (1.84 kB). View file
|
|
similar_images.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from duckduckgo_search import DDGS
|
3 |
+
|
4 |
+
results = DDGS().images(
|
5 |
+
keywords="butterfly",
|
6 |
+
region="wt-wt",
|
7 |
+
safesearch="off",
|
8 |
+
size=None,
|
9 |
+
color="Monochrome",
|
10 |
+
type_image=None,
|
11 |
+
layout=None,
|
12 |
+
license_image=None,
|
13 |
+
max_results=100,
|
14 |
+
)
|
15 |
+
for i in results:
|
16 |
+
print(i['image'])
|
17 |
+
|
18 |
+
|
templates/index.html
ADDED
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Image Captioning & VQA Chatbot</title>
|
7 |
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
|
8 |
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
9 |
+
<style>
|
10 |
+
/* Global Styles */
|
11 |
+
body {
|
12 |
+
background-color: #e5ddd5; /* WhatsApp light gray background */
|
13 |
+
font-family: 'Roboto', sans-serif;
|
14 |
+
display: flex;
|
15 |
+
justify-content: center;
|
16 |
+
align-items: center;
|
17 |
+
min-height: 100vh;
|
18 |
+
margin: 0;
|
19 |
+
color: #333;
|
20 |
+
}
|
21 |
+
|
22 |
+
.chat-container {
|
23 |
+
background-color: #fff;
|
24 |
+
border-radius: 10px;
|
25 |
+
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
|
26 |
+
width: 100%;
|
27 |
+
max-width: 700px;
|
28 |
+
display: flex;
|
29 |
+
flex-direction: column;
|
30 |
+
overflow: hidden;
|
31 |
+
}
|
32 |
+
|
33 |
+
.chat-header {
|
34 |
+
background-color: #25d366; /* WhatsApp green */
|
35 |
+
color: #fff;
|
36 |
+
padding: 20px;
|
37 |
+
text-align: center;
|
38 |
+
font-size: 1.6rem;
|
39 |
+
font-weight: 500;
|
40 |
+
border-top-left-radius: 10px;
|
41 |
+
border-top-right-radius: 10px;
|
42 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
|
43 |
+
}
|
44 |
+
|
45 |
+
.chat-body {
|
46 |
+
flex: 1;
|
47 |
+
padding: 20px;
|
48 |
+
overflow-y: auto;
|
49 |
+
max-height: 400px;
|
50 |
+
background-color: #f1f1f1; /* Light gray background for messages */
|
51 |
+
border-bottom: 2px solid #ddd;
|
52 |
+
}
|
53 |
+
|
54 |
+
.chat-footer {
|
55 |
+
padding: 20px;
|
56 |
+
background-color: #ffffff;
|
57 |
+
display: flex;
|
58 |
+
flex-direction: column;
|
59 |
+
align-items: center;
|
60 |
+
border-bottom-left-radius: 30px;
|
61 |
+
border-bottom-right-radius: 30px;
|
62 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
|
63 |
+
}
|
64 |
+
|
65 |
+
.chat-bubble {
|
66 |
+
max-width: 75%;
|
67 |
+
margin-bottom: 15px;
|
68 |
+
padding: 12px 18px;
|
69 |
+
border-radius: 25px;
|
70 |
+
font-size: 1rem;
|
71 |
+
line-height: 1.5;
|
72 |
+
transition: all 0.3s ease;
|
73 |
+
}
|
74 |
+
|
75 |
+
.chat-bubble.bot {
|
76 |
+
background-color: #e4e6eb; /* Light gray color for bot messages */
|
77 |
+
color: #333;
|
78 |
+
border-top-left-radius: 0;
|
79 |
+
align-self: flex-start;
|
80 |
+
}
|
81 |
+
|
82 |
+
.chat-bubble.user {
|
83 |
+
background-color: #25d366; /* WhatsApp green for user messages */
|
84 |
+
color: #fff;
|
85 |
+
border-top-right-radius: 0;
|
86 |
+
align-self: flex-end;
|
87 |
+
}
|
88 |
+
|
89 |
+
.form-control {
|
90 |
+
border-radius: 5px;
|
91 |
+
padding: 15px;
|
92 |
+
font-size: 1rem;
|
93 |
+
border: 1px solid #ced4da;
|
94 |
+
transition: all 0.3s ease;
|
95 |
+
width: 100%;
|
96 |
+
}
|
97 |
+
|
98 |
+
.form-control:focus {
|
99 |
+
box-shadow: 0 0 8px rgba(108, 99, 255, 0.5);
|
100 |
+
border-color: #25d366;
|
101 |
+
}
|
102 |
+
|
103 |
+
.btn {
|
104 |
+
border-radius: 25px;
|
105 |
+
font-size: 1rem;
|
106 |
+
padding: 12px;
|
107 |
+
width: 100%;
|
108 |
+
font-weight: bold;
|
109 |
+
text-transform: uppercase;
|
110 |
+
transition: all 0.3s ease;
|
111 |
+
}
|
112 |
+
|
113 |
+
.btn-primary {
|
114 |
+
background-color: #25d366; /* WhatsApp green */
|
115 |
+
border: none;
|
116 |
+
}
|
117 |
+
|
118 |
+
.btn-primary:hover {
|
119 |
+
background-color: #128c7e;
|
120 |
+
}
|
121 |
+
|
122 |
+
.upload-container {
|
123 |
+
display: flex;
|
124 |
+
flex-direction: column;
|
125 |
+
align-items: center;
|
126 |
+
gap: 10px;
|
127 |
+
}
|
128 |
+
|
129 |
+
/* Custom file input */
|
130 |
+
.upload-container input[type="file"] {
|
131 |
+
display: none;
|
132 |
+
}
|
133 |
+
|
134 |
+
.upload-btn {
|
135 |
+
padding: 15px 30px;
|
136 |
+
border-radius: 30px;
|
137 |
+
background-color: #25d366; /* WhatsApp green */
|
138 |
+
color: white;
|
139 |
+
font-size: 1rem;
|
140 |
+
cursor: pointer;
|
141 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
142 |
+
transition: all 0.3s ease;
|
143 |
+
}
|
144 |
+
|
145 |
+
.upload-btn:hover {
|
146 |
+
background-color: #128c7e;
|
147 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
148 |
+
}
|
149 |
+
|
150 |
+
.uploaded-image {
|
151 |
+
max-width: 100%;
|
152 |
+
height: auto;
|
153 |
+
border-radius: 10px;
|
154 |
+
margin-top: 15px;
|
155 |
+
margin-bottom: 5px;
|
156 |
+
}
|
157 |
+
|
158 |
+
.similar-images-container {
|
159 |
+
margin-top: 15px;
|
160 |
+
}
|
161 |
+
|
162 |
+
.similar-images-container img {
|
163 |
+
border-radius: 15px;
|
164 |
+
margin: 5px;
|
165 |
+
transition: all 0.3s ease;
|
166 |
+
}
|
167 |
+
|
168 |
+
.similar-images-container img:hover {
|
169 |
+
transform: scale(1.1);
|
170 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
171 |
+
}
|
172 |
+
|
173 |
+
/* Scrollbar styling */
|
174 |
+
.chat-body::-webkit-scrollbar {
|
175 |
+
width: 8px;
|
176 |
+
}
|
177 |
+
|
178 |
+
.chat-body::-webkit-scrollbar-thumb {
|
179 |
+
background-color: #25d366;
|
180 |
+
border-radius: 4px;
|
181 |
+
}
|
182 |
+
.output-image-container{
|
183 |
+
background-color: #e4e6eb; /* Light gray color for bot messages */
|
184 |
+
color: #333;
|
185 |
+
border-top-left-radius: 0;
|
186 |
+
align-self: flex-start;
|
187 |
+
display: flex;
|
188 |
+
justify-content: space-between;
|
189 |
+
}
|
190 |
+
.output-image-container img{
|
191 |
+
width: 50%;
|
192 |
+
height: auto;
|
193 |
+
}
|
194 |
+
.sample{
|
195 |
+
width: 10px;
|
196 |
+
position: absolute;
|
197 |
+
}
|
198 |
+
.download-button {
|
199 |
+
margin-top: 10px;
|
200 |
+
padding: 10px 15px;
|
201 |
+
background-color: #007bff;
|
202 |
+
color: white;
|
203 |
+
border: none;
|
204 |
+
border-radius: 5px;
|
205 |
+
cursor: pointer;
|
206 |
+
font-size: 14px;
|
207 |
+
}
|
208 |
+
|
209 |
+
.download-button:hover {
|
210 |
+
background-color: #0056b3;
|
211 |
+
}
|
212 |
+
|
213 |
+
</style>
|
214 |
+
</head>
|
215 |
+
<body>
|
216 |
+
<div class="chat-container">
|
217 |
+
<div class="chat-header">Image Chatbot</div>
|
218 |
+
<div class="chat-body" id="chat-body">
|
219 |
+
<div class="chat-bubble bot">Hello! Upload an image to get started.</div>
|
220 |
+
|
221 |
+
{% if image_url %}
|
222 |
+
<div class="chat-bubble user">Image uploaded successfully!</div>
|
223 |
+
<div class="output-image-container">
|
224 |
+
<img src="{{ image_url }}" class="uploaded-image" alt="Uploaded Image">
|
225 |
+
<a href="{{ image_url }}" download>
|
226 |
+
<button class="download-button">Download</button>
|
227 |
+
</a>
|
228 |
+
<div class="sample"></div>
|
229 |
+
<img src="{{ input_image_url }}" class="uploaded-image" alt="Uploaded Image">
|
230 |
+
</div>
|
231 |
+
|
232 |
+
<div class="chat-bubble bot">
|
233 |
+
Would you like to generate a caption or ask a question about the image?
|
234 |
+
</div>
|
235 |
+
{% endif %}
|
236 |
+
|
237 |
+
{% if caption %}
|
238 |
+
<div class="chat-bubble bot">
|
239 |
+
Generated Caption: {{ caption }}
|
240 |
+
</div>
|
241 |
+
{% endif %}
|
242 |
+
|
243 |
+
{% if answer %}
|
244 |
+
<div class="chat-bubble bot">
|
245 |
+
Answer to your question: {{ answer }}
|
246 |
+
</div>
|
247 |
+
{% endif %}
|
248 |
+
|
249 |
+
{% if similar_images %}
|
250 |
+
<div class="similar-images-container">
|
251 |
+
<div class="chat-bubble bot">Here are some similar images:</div>
|
252 |
+
<div id="similar-images-list" class="row">
|
253 |
+
{% for img_url in similar_images %}
|
254 |
+
<div class="col-md-3 mb-3 similar-image" style="display: {{ 'block' if loop.index <= 4 else 'none' }};">
|
255 |
+
<img src="{{ img_url }}" class="img-fluid" alt="Similar Image">
|
256 |
+
</div>
|
257 |
+
{% endfor %}
|
258 |
+
</div>
|
259 |
+
<button id="toggle-button" class="btn btn-primary mt-3">Show More</button>
|
260 |
+
</div>
|
261 |
+
{% endif %}
|
262 |
+
</div>
|
263 |
+
|
264 |
+
<div class="chat-footer">
|
265 |
+
{% if not image_url %}
|
266 |
+
<div class="upload-container">
|
267 |
+
<form action="{{ url_for('upload_file') }}" method="POST" enctype="multipart/form-data">
|
268 |
+
<!-- Custom styled file input -->
|
269 |
+
<label class="upload-btn">
|
270 |
+
Choose File
|
271 |
+
<input type="file" class="form-control" id="file" name="file" required>
|
272 |
+
</label>
|
273 |
+
<!-- Image preview and file name display -->
|
274 |
+
<div id="file-name" style="color: #555; font-size: 1rem; margin-top: 10px;"></div>
|
275 |
+
<div id="image-preview" style="margin-top: 10px;">
|
276 |
+
<img id="preview-img" src="#" alt="Image Preview" style="max-width: 100%; display: none; border-radius: 20px;">
|
277 |
+
</div>
|
278 |
+
<button type="submit" class="btn btn-primary">Upload Image</button>
|
279 |
+
</form>
|
280 |
+
</div>
|
281 |
+
|
282 |
+
{% else %}
|
283 |
+
<div class="message-container">
|
284 |
+
<form action="{{ url_for('process_image') }}" method="POST">
|
285 |
+
<input type="hidden" name="image_url" value="{{ image_url }}">
|
286 |
+
<button type="submit" class="btn btn-info" name="caption">Generate Caption</button>
|
287 |
+
</form>
|
288 |
+
<form action="{{ url_for('process_image') }}" method="POST" class="mt-3">
|
289 |
+
<input type="hidden" name="image_url" value="{{ image_url }}">
|
290 |
+
<div class="form-group">
|
291 |
+
<input type="text" class="form-control" id="question" name="question" placeholder="Ask a question about the image" required>
|
292 |
+
</div>
|
293 |
+
<button type="submit" class="btn btn-success" name="vqa">Get Answer</button>
|
294 |
+
</form>
|
295 |
+
</div>
|
296 |
+
{% endif %}
|
297 |
+
</div>
|
298 |
+
</div>
|
299 |
+
|
300 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
301 |
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
|
302 |
+
<script>
|
303 |
+
$(document).ready(function () {
|
304 |
+
// Hide all forms initially
|
305 |
+
$('#caption-form').hide();
|
306 |
+
$('#vqa-form').hide();
|
307 |
+
|
308 |
+
// Show caption form when "Generate Caption" button is clicked
|
309 |
+
$('#generate-caption').click(function() {
|
310 |
+
$('#caption-form').show();
|
311 |
+
$('#vqa-form').hide();
|
312 |
+
});
|
313 |
+
|
314 |
+
// Show VQA form when "Ask a Question" button is clicked
|
315 |
+
$('#ask-question').click(function() {
|
316 |
+
$('#vqa-form').show();
|
317 |
+
$('#caption-form').hide();
|
318 |
+
});
|
319 |
+
|
320 |
+
// Hide the "Please enter a question" alert once an answer is displayed
|
321 |
+
{% if answer %}
|
322 |
+
$('.alert-info').hide();
|
323 |
+
{% endif %}
|
324 |
+
});
|
325 |
+
$(document).ready(function () {
|
326 |
+
// Event listener for the file input change
|
327 |
+
$('#file').on('change', function () {
|
328 |
+
var file = this.files[0];
|
329 |
+
if (file) {
|
330 |
+
// Display the file name
|
331 |
+
$('#file-name').text("Selected file: " + file.name);
|
332 |
+
|
333 |
+
// Create an object URL for the image and display it as a preview
|
334 |
+
var reader = new FileReader();
|
335 |
+
reader.onload = function (e) {
|
336 |
+
$('#preview-img').attr('src', e.target.result).show();
|
337 |
+
};
|
338 |
+
reader.readAsDataURL(file);
|
339 |
+
} else {
|
340 |
+
$('#file-name').text(""); // Reset file name if no file is selected
|
341 |
+
$('#preview-img').hide(); // Hide preview if no file is selected
|
342 |
+
}
|
343 |
+
});
|
344 |
+
});
|
345 |
+
|
346 |
+
|
347 |
+
$(document).ready(function () {
|
348 |
+
const similarImages = $('.similar-image'); // All similar images
|
349 |
+
const toggleButton = $('#toggle-button');
|
350 |
+
let isExpanded = false; // Track state of visibility
|
351 |
+
|
352 |
+
// Click event for "Show More" / "Show Less"
|
353 |
+
toggleButton.on('click', function () {
|
354 |
+
if (isExpanded) {
|
355 |
+
// Collapse to show only the first 4 images
|
356 |
+
similarImages.slice(4).hide();
|
357 |
+
toggleButton.text('Show More');
|
358 |
+
} else {
|
359 |
+
// Expand to show all images
|
360 |
+
similarImages.show();
|
361 |
+
toggleButton.text('Show Less');
|
362 |
+
}
|
363 |
+
isExpanded = !isExpanded; // Toggle state
|
364 |
+
});
|
365 |
+
});
|
366 |
+
|
367 |
+
</script>
|
368 |
+
</body>
|
369 |
+
</html>
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
transer_RRDB_models.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import torch
|
3 |
+
import RRDBNet_arch as arch
|
4 |
+
|
5 |
+
pretrained_net = torch.load('./models/RRDB_ESRGAN_x4.pth')
|
6 |
+
save_path = './models/RRDB_ESRGAN_x4.pth'
|
7 |
+
|
8 |
+
crt_model = arch.RRDBNet(3, 3, 64, 23, gc=32)
|
9 |
+
crt_net = crt_model.state_dict()
|
10 |
+
|
11 |
+
load_net_clean = {}
|
12 |
+
for k, v in pretrained_net.items():
|
13 |
+
if k.startswith('module.'):
|
14 |
+
load_net_clean[k[7:]] = v
|
15 |
+
else:
|
16 |
+
load_net_clean[k] = v
|
17 |
+
pretrained_net = load_net_clean
|
18 |
+
|
19 |
+
print('###################################\n')
|
20 |
+
tbd = []
|
21 |
+
for k, v in crt_net.items():
|
22 |
+
tbd.append(k)
|
23 |
+
|
24 |
+
# directly copy
|
25 |
+
for k, v in crt_net.items():
|
26 |
+
if k in pretrained_net and pretrained_net[k].size() == v.size():
|
27 |
+
crt_net[k] = pretrained_net[k]
|
28 |
+
tbd.remove(k)
|
29 |
+
|
30 |
+
crt_net['conv_first.weight'] = pretrained_net['model.0.weight']
|
31 |
+
crt_net['conv_first.bias'] = pretrained_net['model.0.bias']
|
32 |
+
|
33 |
+
for k in tbd.copy():
|
34 |
+
if 'RDB' in k:
|
35 |
+
ori_k = k.replace('RRDB_trunk.', 'model.1.sub.')
|
36 |
+
if '.weight' in k:
|
37 |
+
ori_k = ori_k.replace('.weight', '.0.weight')
|
38 |
+
elif '.bias' in k:
|
39 |
+
ori_k = ori_k.replace('.bias', '.0.bias')
|
40 |
+
crt_net[k] = pretrained_net[ori_k]
|
41 |
+
tbd.remove(k)
|
42 |
+
|
43 |
+
crt_net['trunk_conv.weight'] = pretrained_net['model.1.sub.23.weight']
|
44 |
+
crt_net['trunk_conv.bias'] = pretrained_net['model.1.sub.23.bias']
|
45 |
+
crt_net['upconv1.weight'] = pretrained_net['model.3.weight']
|
46 |
+
crt_net['upconv1.bias'] = pretrained_net['model.3.bias']
|
47 |
+
crt_net['upconv2.weight'] = pretrained_net['model.6.weight']
|
48 |
+
crt_net['upconv2.bias'] = pretrained_net['model.6.bias']
|
49 |
+
crt_net['HRconv.weight'] = pretrained_net['model.8.weight']
|
50 |
+
crt_net['HRconv.bias'] = pretrained_net['model.8.bias']
|
51 |
+
crt_net['conv_last.weight'] = pretrained_net['model.10.weight']
|
52 |
+
crt_net['conv_last.bias'] = pretrained_net['model.10.bias']
|
53 |
+
|
54 |
+
torch.save(crt_net, save_path)
|
55 |
+
print('Saving to ', save_path)
|