Spaces:
Runtime error
Runtime error
Commit
·
ab39ad4
1
Parent(s):
9705a2a
solved issue with number of authors and number of neighbors
Browse files- app.py +15 -20
- static/js/parameters.js +1 -1
app.py
CHANGED
|
@@ -131,6 +131,16 @@ def home():
|
|
| 131 |
def serve_static(filename):
|
| 132 |
return send_from_directory('static', filename)
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
@app.route('/select_preset/<int:preset_id>')
|
| 135 |
def select_preset(preset_id):
|
| 136 |
if preset_id not in PRESET_IMAGES:
|
|
@@ -141,14 +151,7 @@ def select_preset(preset_id):
|
|
| 141 |
image = Image.open(image_path).convert('RGB')
|
| 142 |
|
| 143 |
# Use default parameters for presets
|
| 144 |
-
params =
|
| 145 |
-
'subscription': 12,
|
| 146 |
-
'num_generations': 60,
|
| 147 |
-
'author_share': 5,
|
| 148 |
-
'ro_share': 10,
|
| 149 |
-
'num_users_k': 500,
|
| 150 |
-
'num_neighbors': 10
|
| 151 |
-
}
|
| 152 |
|
| 153 |
# Get features and search
|
| 154 |
features = get_ft(model, image)
|
|
@@ -181,7 +184,8 @@ def select_preset(preset_id):
|
|
| 181 |
params['author_share'],
|
| 182 |
params['ro_share'],
|
| 183 |
params['num_users_k'],
|
| 184 |
-
similarities
|
|
|
|
| 185 |
)
|
| 186 |
|
| 187 |
# Build final results
|
|
@@ -199,16 +203,6 @@ def select_preset(preset_id):
|
|
| 199 |
except Exception as e:
|
| 200 |
return jsonify({'error': str(e)}), 500
|
| 201 |
|
| 202 |
-
DEFAULT_PARAMS = {
|
| 203 |
-
'subscription': 12,
|
| 204 |
-
'num_generations': 60,
|
| 205 |
-
'author_share': 5,
|
| 206 |
-
'ro_share': 10,
|
| 207 |
-
'num_users_k': 500,
|
| 208 |
-
'num_neighbors': 8,
|
| 209 |
-
'num_authors': 1800
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
@app.route('/process', methods=['POST'])
|
| 213 |
def process_image():
|
| 214 |
if 'image' not in request.files:
|
|
@@ -262,7 +256,8 @@ def process_image():
|
|
| 262 |
params['author_share'],
|
| 263 |
params['ro_share'],
|
| 264 |
params['num_users_k'],
|
| 265 |
-
similarities
|
|
|
|
| 266 |
)
|
| 267 |
|
| 268 |
# Build final results
|
|
|
|
| 131 |
def serve_static(filename):
|
| 132 |
return send_from_directory('static', filename)
|
| 133 |
|
| 134 |
+
DEFAULT_PARAMS = {
|
| 135 |
+
'subscription': 12,
|
| 136 |
+
'num_generations': 60,
|
| 137 |
+
'author_share': 5,
|
| 138 |
+
'ro_share': 10,
|
| 139 |
+
'num_users_k': 500,
|
| 140 |
+
'num_neighbors': 10,
|
| 141 |
+
'num_authors': 20000
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
@app.route('/select_preset/<int:preset_id>')
|
| 145 |
def select_preset(preset_id):
|
| 146 |
if preset_id not in PRESET_IMAGES:
|
|
|
|
| 151 |
image = Image.open(image_path).convert('RGB')
|
| 152 |
|
| 153 |
# Use default parameters for presets
|
| 154 |
+
params = DEFAULT_PARAMS.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
# Get features and search
|
| 157 |
features = get_ft(model, image)
|
|
|
|
| 184 |
params['author_share'],
|
| 185 |
params['ro_share'],
|
| 186 |
params['num_users_k'],
|
| 187 |
+
similarities,
|
| 188 |
+
params['num_authors']
|
| 189 |
)
|
| 190 |
|
| 191 |
# Build final results
|
|
|
|
| 203 |
except Exception as e:
|
| 204 |
return jsonify({'error': str(e)}), 500
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
@app.route('/process', methods=['POST'])
|
| 207 |
def process_image():
|
| 208 |
if 'image' not in request.files:
|
|
|
|
| 256 |
params['author_share'],
|
| 257 |
params['ro_share'],
|
| 258 |
params['num_users_k'],
|
| 259 |
+
similarities,
|
| 260 |
+
params['num_authors']
|
| 261 |
)
|
| 262 |
|
| 263 |
# Build final results
|
static/js/parameters.js
CHANGED
|
@@ -39,7 +39,7 @@ Note: Exact figures aren't public, but Midjourney is estimated to have 2 to 5 mi
|
|
| 39 |
},
|
| 40 |
num_authors: {
|
| 41 |
label: "Total Authors",
|
| 42 |
-
defaultValue:
|
| 43 |
tooltip: "Total number of authors in the system that could potentially receive rewards"
|
| 44 |
}
|
| 45 |
};
|
|
|
|
| 39 |
},
|
| 40 |
num_authors: {
|
| 41 |
label: "Total Authors",
|
| 42 |
+
defaultValue: 20000,
|
| 43 |
tooltip: "Total number of authors in the system that could potentially receive rewards"
|
| 44 |
}
|
| 45 |
};
|