editGAN_release icon indicating copy to clipboard operation
editGAN_release copied to clipboard

fail to run the app

Open cannotseeme opened this issue 3 years ago • 7 comments

Hi ! thanks for the great contribution. I've got some trouble when I tried to run the app.Similar to #8, I managed to setup the app but it seemed the UI is not working. All the buttons are not functional. The window is just like this:

2022-05-09 14-31-38

And my log info is as follow: python run_app.py

  • Serving Flask app 'run_app' (lazy loading)
  • Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
  • Debug mode: off
  • Running on all addresses (0.0.0.0) WARNING: This is a development server. Do not use it in a production deployment.
  • Running on http://127.0.0.1:8888
  • Running on http://192.168.1.111:8888 (Press CTRL+C to quit) Load stylegan from, ./checkpoint/stylegan_pretrain/stylegan2_networks_stylegan2-car-config-f.pt at res, 512 make_mean_latent Load Classifier path, ./checkpoint/datasetgan_pretrain/classifier Setting up Perceptual loss... Loading model from: /home/hp/editGAN/lpips/weights/v0.1/vgg.pth ...[net-lin [vgg]] initialized ...Done 0%| | 0/10 [00:00<?, ?it/s]/home/hp/.conda/envs/editGAN/lib/python3.8/site-packages/torch/nn/functional.py:3631: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. warnings.warn( 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:08<00:00, 1.24it/s] TOOL init!! 192.168.1.111 - - [09/May/2022 14:22:31] "GET / HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:22:31] "GET /static/demo.css HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:22:31] "GET /static/demo_origin.js HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:22:31] "GET /static/nvidia.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:22:31] "GET /static/loading.gif HTTP/1.1" 404 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/brush_circle.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/brush_square.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/brush_diamond.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/paint-brush.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/paint-can.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/eyedropper.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/undo.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/save.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/run.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/random.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/0.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/1.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/2.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/3.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/5.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/4.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/6.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/7.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/8.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/10.jpg HTTP/1.1" 404 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/images/car_real/9.jpg HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:41] "GET /static/info.png HTTP/1.1" 200 - 192.168.1.111 - - [09/May/2022 14:24:42] "GET /favicon.ico HTTP/1.1" 404 -

I have no idea what's wrong with it. Any idea? Thank you!

cannotseeme avatar May 09 '22 06:05 cannotseeme

backend starts well. Can you show your frontend logs? Using Inspect of google Chrome

arieling avatar May 09 '22 14:05 arieling

backend starts well. Can you show your frontend logs? Using Inspect of google Chrome

Yes, here's the log info: 图片 It looks like the .js was not loaded correctly.

cannotseeme avatar May 09 '22 16:05 cannotseeme

are you on linux?

arieling avatar May 09 '22 16:05 arieling

are you on linux?

yes, I'm running it on the ubuntu 20.04.

cannotseeme avatar May 10 '22 03:05 cannotseeme

what's the path where you run frontend from?

arieling avatar May 10 '22 20:05 arieling

what's the path where you run frontend from?

The backend was directly running on the terminal. And I followed the guideline and opened the 'localhost:8888' on the Google Chrome.

cannotseeme avatar May 11 '22 04:05 cannotseeme

` import imageio

from models.EditGAN.EditGAN_tool import Tool import numpy as np

import PIL import os import torch import numpy as np

import matplotlib.pyplot as plt from PIL import Image from torchvision import transforms import cv2 from tqdm import tqdm

car_32_palette =[ 255, 255, 255, 238, 229, 102, 0, 0, 0, 124, 99 , 34, 193 , 127, 15, 106, 177, 21, 248 ,213 , 42, 252 , 155, 83, 220 ,147 , 77, 99 , 83 , 3, 116 , 116 , 138, 63 ,182 , 24, 200 ,226 , 37, 225 , 184 , 161, 233 , 5 ,219, 142 , 172 ,248, 153 , 112 , 146, 38 ,112 , 254, 229 , 30 ,141, 115 ,208 , 131, 52 , 83 ,84, 229 , 63 , 110, 194 , 87 , 125, 225, 96 ,18, 73 ,139, 226, 172 , 143 , 16, 169 , 101 , 111, 31 , 102 , 211, 104 , 131 , 101, 70 ,168 ,156, 183 , 242 , 209, 72 ,184 , 226]

def colorize_mask(mask, palette): # mask: numpy array of the mask new_mask = Image.fromarray(mask.astype(np.uint8)).convert('P') new_mask.putpalette(palette) return np.array(new_mask.convert('RGB'))

if name == 'main':

tool = Tool()

root_path = '/pub/data/ligang/projects/editGAN_release/images/choosed_data1_1k/'
save_root_path = '/pub/data/ligang/projects/editGAN_release/masks/choosed_data1_1k/'

for root, dirs, files in tqdm(os.walk(root_path)):
    for f in files:
        img_path = os.path.join(root, f)
        print(img_path)
        # load an image
        img = Image.open(img_path)
        resize_fun = transforms.Resize((384, 512), interpolation=PIL.Image.BICUBIC)
        img = resize_fun(img)
        img = np.array(img)  # / 256.

        assert img.shape == (384, 512, 3)
        canvas = np.zeros([512, 512, 3], dtype=np.uint8)
        canvas[(512-384) // 2: (512+384) // 2, :, :] = img

        canvas = Image.fromarray(canvas, 'RGB')

        img_out, img_seg_final, optimized_latent, optimized_noise = tool.run_embedding(canvas)

        # mask_final = cv2.resize(img_seg_final, (256, 256), interpolation=cv2.INTER_NEAREST)

        npy_file_name = img_path.replace('jpg','npy').split('/')[-1]
        np.save(os.path.join(save_root_path, npy_file_name), mask_final)

`

Consider using the simple inference script. Only need to update root_path and save_root_path as your paths. Run it, then the mask maps are saved in save_root_path as a type of Numpy file.

ucasligang avatar Jun 09 '22 09:06 ucasligang