Spaces:
Sleeping
Sleeping
upgrade
Browse files- compo-singleone-v2-dev-acc.py +23 -16
compo-singleone-v2-dev-acc.py
CHANGED
@@ -93,7 +93,7 @@ else:
|
|
93 |
#######################################################
|
94 |
|
95 |
def get_model_simplified_name_from_dirname(dirname):
|
96 |
-
return dirname.replace("model_","").replace("_864x","").replace("_864","").replace("_new","")
|
97 |
|
98 |
def get_padded_checkpoint_no_from_filename(checkpoint_filename):
|
99 |
match = re.search(r'ckpt-(\d+)', checkpoint_filename)
|
@@ -107,7 +107,7 @@ def get_padded_checkpoint_no_from_filename(checkpoint_filename):
|
|
107 |
|
108 |
found_model='none'
|
109 |
found_model_checkpoint='0'
|
110 |
-
|
111 |
#########################################################
|
112 |
# SETUP
|
113 |
|
@@ -115,7 +115,7 @@ checkpoint_info='0'
|
|
115 |
runway_files = runway.file(is_directory=True)
|
116 |
@runway.setup(options={'styleCheckpoint': runway_files})
|
117 |
def setup(opts):
|
118 |
-
global found_model,found_model_checkpoint
|
119 |
sess = tf.Session()
|
120 |
# sess2 = tf.Session()
|
121 |
# sess3 = tf.Session()
|
@@ -186,7 +186,7 @@ def setup(opts):
|
|
186 |
#ckpt2 = tf.train.get_checkpoint_state(checkpoint2_dir)
|
187 |
# ckpt3 = tf.train.get_checkpoint_state(checkpoint3_dir)
|
188 |
ckpt_name = os.path.basename(ckpt.model_checkpoint_path)
|
189 |
-
|
190 |
found_model_checkpoint= get_padded_checkpoint_no_from_filename(ckpt_name)
|
191 |
|
192 |
#ckpt2_name = os.path.basename(ckpt2.model_checkpoint_path)
|
@@ -203,30 +203,36 @@ def setup(opts):
|
|
203 |
# models.m3 = m3
|
204 |
return models
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
@runway.command('meta2', inputs=meta_inputs, outputs=meta_outputs)
|
210 |
-
def get_geta(models, inp):
|
211 |
-
global found_model,found_model_checkpoint,checkpoint_info
|
212 |
meta_value = inp['meta']
|
213 |
-
#convert RUNWAY_FILES to string
|
214 |
json_return = {
|
215 |
-
"meta":
|
216 |
"model": found_model,
|
217 |
-
"files": str(runway_files),
|
218 |
"checkpoint": found_model_checkpoint
|
219 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
# "files": "nothing yet"
|
221 |
print(json_return)
|
222 |
-
return json_return
|
|
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
#@STCGoal add number or text to specify resolution of the three pass
|
228 |
inputs={'contentImage': runway.image,'x1':number(default=1024,min=24,max=17000),'x2':number(default=0,min=-99,max=99)}
|
229 |
-
outputs={'stylizedImage': runway.image,'totaltime':number,'x1': number,'c1':number,'model1name':text}
|
230 |
|
231 |
@runway.command('stylize', inputs=inputs, outputs=outputs)
|
232 |
def stylize(models, inp):
|
@@ -342,7 +348,8 @@ def stylize(models, inp):
|
|
342 |
stop = time.time()
|
343 |
totaltime = stop - start
|
344 |
print("The time of the run:", totaltime)
|
345 |
-
|
|
|
346 |
return res2
|
347 |
|
348 |
|
|
|
93 |
#######################################################
|
94 |
|
95 |
def get_model_simplified_name_from_dirname(dirname):
|
96 |
+
return dirname.replace("model_","").replace("_864x","").replace("_864","").replace("_new","").replace("-864","")
|
97 |
|
98 |
def get_padded_checkpoint_no_from_filename(checkpoint_filename):
|
99 |
match = re.search(r'ckpt-(\d+)', checkpoint_filename)
|
|
|
107 |
|
108 |
found_model='none'
|
109 |
found_model_checkpoint='0'
|
110 |
+
|
111 |
#########################################################
|
112 |
# SETUP
|
113 |
|
|
|
115 |
runway_files = runway.file(is_directory=True)
|
116 |
@runway.setup(options={'styleCheckpoint': runway_files})
|
117 |
def setup(opts):
|
118 |
+
global found_model,found_model_checkpoint
|
119 |
sess = tf.Session()
|
120 |
# sess2 = tf.Session()
|
121 |
# sess3 = tf.Session()
|
|
|
186 |
#ckpt2 = tf.train.get_checkpoint_state(checkpoint2_dir)
|
187 |
# ckpt3 = tf.train.get_checkpoint_state(checkpoint3_dir)
|
188 |
ckpt_name = os.path.basename(ckpt.model_checkpoint_path)
|
189 |
+
|
190 |
found_model_checkpoint= get_padded_checkpoint_no_from_filename(ckpt_name)
|
191 |
|
192 |
#ckpt2_name = os.path.basename(ckpt2.model_checkpoint_path)
|
|
|
203 |
# models.m3 = m3
|
204 |
return models
|
205 |
|
206 |
+
def _make_meta_as_json(inp):
|
207 |
+
global found_model,found_model_checkpoint
|
|
|
|
|
|
|
|
|
208 |
meta_value = inp['meta']
|
|
|
209 |
json_return = {
|
210 |
+
"meta": meta_value,
|
211 |
"model": found_model,
|
|
|
212 |
"checkpoint": found_model_checkpoint
|
213 |
}
|
214 |
+
return json_return
|
215 |
+
|
216 |
+
|
217 |
+
meta_inputs={'meta':text}
|
218 |
+
meta_outputs={'meta':text,'model':text,'files':text,'checkpoint':text}
|
219 |
+
|
220 |
+
@runway.command('meta2', inputs=meta_inputs, outputs=meta_outputs)
|
221 |
+
def get_geta(models, inp):
|
222 |
+
global found_model,found_model_checkpoint
|
223 |
+
|
224 |
+
json_return = _make_meta_as_json(inp)
|
225 |
# "files": "nothing yet"
|
226 |
print(json_return)
|
227 |
+
return json_return
|
228 |
+
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
#@STCGoal add number or text to specify resolution of the three pass
|
234 |
inputs={'contentImage': runway.image,'x1':number(default=1024,min=24,max=17000),'x2':number(default=0,min=-99,max=99)}
|
235 |
+
outputs={'stylizedImage': runway.image,'totaltime':number,'x1': number,'c1':number,'model1name':text,'meta':text}
|
236 |
|
237 |
@runway.command('stylize', inputs=inputs, outputs=outputs)
|
238 |
def stylize(models, inp):
|
|
|
348 |
stop = time.time()
|
349 |
totaltime = stop - start
|
350 |
print("The time of the run:", totaltime)
|
351 |
+
meta_data = _make_meta_as_json(inp)
|
352 |
+
res2 = dict(stylizedImage=img,totaltime=totaltime,x1=x1,model1name=model1name,c1=c1,meta=meta_data)
|
353 |
return res2
|
354 |
|
355 |
|