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

fail to run the app #13

Open
cannotseeme opened this issue May 9, 2022 · 7 comments
Open

fail to run the app #13

cannotseeme opened this issue May 9, 2022 · 7 comments

Comments

@cannotseeme
Copy link

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!

@arieling
Copy link
Collaborator

arieling commented May 9, 2022

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

@cannotseeme
Copy link
Author

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.

@arieling
Copy link
Collaborator

arieling commented May 9, 2022

are you on linux?

@cannotseeme
Copy link
Author

are you on linux?

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

@arieling
Copy link
Collaborator

what's the path where you run frontend from?

@cannotseeme
Copy link
Author

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.

@ucasligang
Copy link

ucasligang commented Jun 9, 2022

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

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

3 participants