Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in server when submitting sketch. #7

Open
EmoryQ opened this issue Apr 24, 2019 · 13 comments
Open

Error in server when submitting sketch. #7

EmoryQ opened this issue Apr 24, 2019 · 13 comments

Comments

@EmoryQ
Copy link

EmoryQ commented Apr 24, 2019

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:

PS C:\Users\Sequoia\smartsketch\smart-sketch\backend> python .\server.py
{'help': None, 'logging': 'info', 'log_to_stderr': None, 'log_file_prefix': None, 'log_file_max_size': 100000000, 'log_file_num_backups': 10, 'log_rotate_when': 'midnight', 'log_rotate_interval': 1, 'log_rotate_mode': 'size', 'debug': False, 'port': 80, 'address': '127.0.0.1', 'template_path': '.\\templates'}
[I 190424 11:10:56 web:2246] 200 GET / (127.0.0.1) 2.00ms
[I 190424 11:10:56 web:2246] 200 GET /static/style.css (127.0.0.1) 230.73ms
[I 190424 11:10:56 web:2246] 200 GET /static/drawingboard.min.js (127.0.0.1) 2.00ms
[I 190424 11:10:58 server:98] Recieved a file
.\img/color.png .\dataset/val_inst/greyscale.png
{(56, 79, 131): 'sea', (239, 239, 239): 'clouds', (44, 30, 22): 'dirt', (93, 110, 50): 'bush', (183, 210, 78): 'grass', (60, 59, 75): 'mountain', (152, 126, 106): 'road', (117, 158, 223): 'sky-other', (53, 38, 19): 'tree', (99, 99, 99): 'pavement', (230, 112, 182): 'flower', (193, 195, 201): 'fog', (119, 108, 45): 'hill', (191, 96, 44): 'leaves', (50, 96, 77): 'river'}
[E 190424 11:10:59 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\Sequoia\AppData\Local\Programs\Python\Python37\lib\site-packages\tornado\web.py", line 1697, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File ".\server.py", line 113, in post
        make_processable(greyscale_fname, output_color_file)
      File ".\server.py", line 81, in make_processable
        copy_file(ouptut_greyscale_file, ouptut_greyscale_file_labels)
      File ".\server.py", line 65, in copy_file
        subprocess.check_output(command_string.split(" "))
      File "C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 472, in run
        with Popen(*popenargs, **kwargs) as process:
      File "C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 775, in __init__
        restore_signals, start_new_session)
      File "C:\Users\Sequoia\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1178, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified
[E 190424 11:10:59 web:2246] 500 POST /upload (127.0.0.1) 133.84ms
@EmoryQ
Copy link
Author

EmoryQ commented Apr 24, 2019

To get to the UI, after launching the server, I go to 127.0.0.1:80 in the browser.

@noyoshi
Copy link
Owner

noyoshi commented Apr 24, 2019

@EmoryQ could you throw some print statements in the function copy_file so we can see what it was looking for?

@EmoryQ
Copy link
Author

EmoryQ commented Apr 24, 2019

@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.

@noyoshi
Copy link
Owner

noyoshi commented Apr 24, 2019

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.

@EmoryQ
Copy link
Author

EmoryQ commented Apr 24, 2019

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

@noyoshi
Copy link
Owner

noyoshi commented Apr 24, 2019

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.

@EmoryQ
Copy link
Author

EmoryQ commented Apr 24, 2019

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)

@EmoryQ
Copy link
Author

EmoryQ commented Apr 25, 2019

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...

@EmoryQ
Copy link
Author

EmoryQ commented May 9, 2019

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!!

@SeavanMao
Copy link

modify these lines and make it~

#copy_file(ouptut_greyscale_file, ouptut_greyscale_file_labels)
shutil.copyfile(ouptut_greyscale_file, ouptut_greyscale_file_labels)

#copy_file(ouptut_greyscale_file, ouptut_greyscale_file_img)
shutil.copyfile(ouptut_greyscale_file, ouptut_greyscale_file_img)

@parkzinc
Copy link

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

@Dominioncher
Copy link

Dominioncher commented May 24, 2019

@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)

@MyGoodSir
Copy link

@parkzinc you have to import shutil at the top of server.py
after implementing all these changes it ended up working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants