Run offline using GPU

#15
by beyondtime - opened

Is there any plan for this to be able to run offline in the future?

Please check out our GitHub code: https://github.com/sczhou/CodeFormer

Is there any plan for this to be able to run offline in the future?

Try my version of Dockerfile

FROM pytorch/pytorch:latest

RUN apt update && apt install -y git ffmpeg libgl1 libglib2.0-dev libsm6 libxext6 && \
    git clone https://huggingface.co/spaces/sczhou/CodeFormer /cf

WORKDIR /cf

RUN pip3 install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple

RUN pip install gradio && python -m pip install markupsafe==2.0.1

RUN apt install -y wget

WORKDIR /cf/CodeFormer/weights/CodeFormer
RUN wget https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth 
WORKDIR /cf/CodeFormer/weights/facelib
RUN wget https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth
RUN wget https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth
WORKDIR /cf/CodeFormer/weights/realesrgan
RUN wget https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/RealESRGAN_x2plus.pth

WORKDIR /cf

RUN sed -i '$c demo.launch(server_name="0.0.0.0")' app.py

EXPOSE 7860

CMD [ "python", "app.py" ]

success?

I was able to get this container built with the above and it launches successfully. Does this use a web GUI? My apologies for the question. This is new to me.

Paste the code to an empty file named Dockerfile, and run docker build -t codeformer . to build the image named codeformer. As you have built an image, this might not needed.

Then run docker run -p 7860:7860 --name codeformer codeformer
Run docker imagesto list all the images you have built and pulled. find the image you have built and replace the second "codeformer" with this image id or name if mine is different from yours. if you have a gpu, please add the argument --gpus=allafter "run" but it might still work on cpu because I am also new.

Browser visit localhost:7860to use the same GUI as this page. Don't close the browser until the process is done, otherwise resources are occupied but the results are never accessible.

I tried to edit my previous post but because my account is new it wouldn't let me. Thank you for the reply! I am able to run this locally inside of a docker instance now. It uses CPU instead of GPU, but I am okay with that since I am also running a local install of Stable Diffusion via Automatic1111. SD uses the GPU and I can continue to generate images with that while I do some image enhancements with CodeFormer locally. It works well with both generated images as well as photos I've taken in the distant past before digital photographs were as high quality as film.
Cheers!

hi, how do i run the dockerfile please? i'm absolutely noob at this. i tried duplicating the space but after 6 months, my private space no longer works.

Sign up or log in to comment