fix bug
Build-Deploy-Actions
Details
Build-Deploy-Actions
Details
This commit is contained in:
parent
55701c8e88
commit
5360b39c98
|
@ -1,11 +1,13 @@
|
|||
FROM python:3.8.13
|
||||
FROM artifacts.iflytek.com/docker-private/atp/base_image_for_ailab:0.0.1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . /app
|
||||
COPY bird.png requirements.txt /app/
|
||||
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
|
||||
RUN pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple
|
||||
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
COPY app.py /app
|
||||
|
||||
CMD ["python", "app.py"]
|
||||
|
|
9
app.py
9
app.py
|
@ -25,21 +25,22 @@ controlnet = ControlNetModel.from_pretrained(
|
|||
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
||||
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16
|
||||
)
|
||||
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
||||
pipe.enable_xformers_memory_efficient_attention()
|
||||
pipe.enable_model_cpu_offload()
|
||||
|
||||
def image2image(image, prompt):
|
||||
#image = np.array(image)
|
||||
|
||||
low_threshold = 100
|
||||
high_threshold = 200
|
||||
|
||||
|
||||
image = cv2.Canny(image, low_threshold, high_threshold)
|
||||
image = image[:, :, None]
|
||||
image = np.concatenate([image, image, image], axis=2)
|
||||
image = Image.fromarray(image)
|
||||
|
||||
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
||||
pipe.enable_xformers_memory_efficient_attention()
|
||||
pipe.enable_model_cpu_offload()
|
||||
image = pipe(prompt, image, num_inference_steps=20).images[0]
|
||||
|
||||
return image
|
||||
|
@ -60,4 +61,4 @@ with gr.Blocks(theme=theme, css="footer {visibility: hidden}") as demo:
|
|||
examples = gr.Examples(examples=[['bird.png', 'bird']], inputs=[image, prompt], label="例子")
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.queue(concurrency_count=3).launch(server_name = "0.0.0.0")
|
||||
demo.queue(concurrency_count=3).launch(server_name = "0.0.0.0", share=True)
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
controlnet_aux
|
||||
xformers
|
||||
diffusers
|
||||
torch
|
||||
gradio == 3.27.0
|
||||
transformers
|
||||
accelerate
|
||||
Pillow
|
||||
numpy
|
||||
|
|
Loading…
Reference in New Issue