Open EmoryQ opened 5 years ago
To get to the UI, after launching the server, I go to 127.0.0.1:80 in the browser.
@EmoryQ could you throw some print statements in the function copy_file
so we can see what it was looking for?
@noyoshi So I added some print statements through the code, and in the copy_file function like this:
def copy_file(old="avon.png", new="avon.png"):
command_string = "cp " + old + " " + new
print ("copy_file:" "cp " + old + " " + new)
subprocess.check_output(command_string.split(" "))
print(command_string)
The powershell output shows:
copy_file:cp dataset/val_inst/greyscale.png dataset/val_label/greyscale.png
[E 190424 18:13:49 web:1788] Uncaught exception POST /upload (127.0.0.1)
So it appears to crash the first time that the copy_file function is ran, after the command_string = "cp " + old + " " + new
and before/during subprocess.check_output(command_string.split(" "))
I'm still not sure what is going on to cause this error. I'm not extremely familiar with python, and I'm not sure what the subprocess.check_output(command_string.split(" "))
command is doing.
Right here I am doing a bit of hacky stuff, I am calling the shell command cp dataset/val_inst/greyscale.png dataset/val_label/greyscale.png
to move the image around to directories the model wants it in. Do you know if you have the folder dataset
? And if so, dataset/val_inst
and dataset/val_label
? It looks like it is failing because it cannot find those folders / files.
I do have those folders. The server does create a greyscale.png of the drawing in the val_inst folder, but it does not copy it to val_label folder.
Edit: Correction
Hmm, that is weird. I think it might be a Widows specific bug then. Later today I'll try running this on a windows machine to see if I can reproduce it. Ideally we wouldn't even be calling cp
from Python - so maybe it is time that we do the file manipulation directly from Python.
So, as a workaround: Instead of running the color_to_grey function once and then doing the copy_file, I just ran the color_to_grey function 3 times to create and put the file in the 3 locations that the copy_file function was going to send them to.
Now, however, when I click "Convert Photo" I get an "X" on the webpage where the hourglass would normally be, and I get an image of a livingroom in the /img folder (this is the same image i get when I run test.py)
After I click "Convert to Photo", the hourglass does spin for a little bit, and the PoweShell does pause and think for a little bit. On the PowerShell, after it shows the 3 greyscale conversions it then shows:
----------------- Options ---------------
aspect_ratio: 1.0
batchSize: 1
cache_filelist_read: True
cache_filelist_write: True
checkpoints_dir: ./checkpoints
coco_no_portraits: False
contain_dontcare_label: True
crop_size: 256
dataroot: dataset/
dataset_mode: coco
display_winsize: 256
gpu_ids: -1
how_many: inf
init_type: xavier
init_variance: 0.02
isTrain: False [default: None]
label_nc: 182
load_from_opt_file: False
load_size: 256
max_dataset_size: 9223372036854775807
model: pix2pix
nThreads: 0
name: coco_pretrained
nef: 16
netG: spade
ngf: 64
no_flip: True
no_instance: False
norm_D: spectralinstance
norm_E: spectralinstance
norm_G: spectralspadesyncbatch3x3
num_upsampling_layers: normal
output_nc: 3
phase: test
preprocess_mode: resize_and_crop
results_dir: ./results/
serial_batches: True
use_vae: False
which_epoch: latest
z_dim: 256
----------------- End -------------------
dataset [CocoDataset] of size 5002 was created
Network [SPADEGenerator] was created. Total number of parameters: 97.5 million. To see the architecture, do print(network).
<torch.utils.data.dataloader.DataLoader object at 0x00000228E705C470>
torch.Size([1, 1, 256, 256])
C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\modules\upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.{} is deprecated. Use nn.functional.interpolate instead.".format(self.name))
C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\site-packages\torch\nn\functional.py:1320: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")
False
C:\Users\Sequoia\smartsketch\smart-sketch\backend\img IMAGEDIR
saved image to C:\Users\Sequoia\smartsketch\smart-sketch\backend\img\8a880f3f-2b5d-49df-ae6e-306179a3196e.png
export_image_location: C:\Users\Sequoia\smartsketch\smart-sketch\backend\img\8a880f3f-2b5d-49df-ae6e-306179a3196e.png
static_image_location: C:\Users\Sequoia\smartsketch\smart-sketch\backend\img\8a880f3f-2b5d-49df-ae6e-306179a3196e.png
[I 190425 09:36:22 web:2246] 200 POST /upload (127.0.0.1) 14722.69ms
[W 190425 09:36:22 web:2246] 404 GET /C:/Users/Sequoia/smartsketch/smart-sketch/backend/img/8a880f3f-2b5d-49df-ae6e-306179a3196e.png (127.0.0.1) 0.00ms
But then I get an "X" (like missing image) on the webpage UI. I wonder what I am missing...
It would appear that it is most likely, as you said, a windows specific bug. I'll wait for a fix, and had fun using the smartsketch.xyz when it's up and running! Thanks!!
modify these lines and make it~
shutil.copyfile(ouptut_greyscale_file, ouptut_greyscale_file_labels)
shutil.copyfile(ouptut_greyscale_file, ouptut_greyscale_file_img)
Thank you @SeavanMao ! im with the same problem now the server.py says :
[E 190510 08:32:05 web:1788] Uncaught exception POST /upload (127.0.0.1) HTTPServerRequest(protocol='http', host='127.0.0.1', method='POST', uri='/upload', version='HTTP/1.1', remote_ip='127.0.0.1') Traceback (most recent call last): File "C:\Users\PrkZ\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\web.py", line 1697, in _execute result = method(*self.path_args, **self.path_kwargs) File "server.py", line 115, in post make_processable(greyscale_fname, output_color_file) File "server.py", line 83, in make_processable shutil.copyfile(ouptut_greyscale_file, ouptut_greyscale_file_labels) NameError: name 'shutil' is not defined [E 190510 08:32:05 web:2246] 500 POST /upload (127.0.0.1) 155.14ms
@SeavanMao resolve problem on windows with server error but also we need to parse path to result image. At windows we have '\\' splitter in path )
Try at this function change / splitter to \\
def parse_static_filepath(filepath): split_filepath = filepath.split('\\') while len(split_filepath) > 2: split_filepath.pop(0) return '/'.join(split_filepath)
@parkzinc you have to import shutil at the top of server.py after implementing all these changes it ended up working for me
I have tried to set up everything per the instructions, and when I create a sketch and click "Convert Photo", I only get a spinning hourglass. The terminal says:
"FileNotFoundError: [WinError 2] The system cannot find the file specified" , but I'm not sure what file it is looking for.
This is the complete output from Powershell from the server.py: