From 85779cda69bc206d69cf04e81e1dcd502152d60f Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Wed, 30 Aug 2023 20:05:48 +0700 Subject: [PATCH 1/3] fix(inference): Update ggml sd api to sync api --- jan-inference/sd/main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jan-inference/sd/main.py b/jan-inference/sd/main.py index bf77767f2..e424b01fe 100644 --- a/jan-inference/sd/main.py +++ b/jan-inference/sd/main.py @@ -8,11 +8,12 @@ from pydantic import BaseModel app = FastAPI() -OUTPUT_DIR = "output" +OUTPUT_DIR = os.environ.get("OUTPUT_DIR", "output") SD_PATH = os.environ.get("SD_PATH", "./sd") MODEL_DIR = os.environ.get("MODEL_DIR", "./models") MODEL_NAME = os.environ.get( "MODEL_NAME", "v1-5-pruned-emaonly-ggml-model-q5_0.bin") +BASE_URL = os.environ.get("BASE_URL", "http://localhost:8000") class Payload(BaseModel): @@ -51,7 +52,7 @@ def run_command(payload: Payload, filename: str): ] try: - subprocess.run(command, timeout=5*60) + subprocess.run(command) except subprocess.CalledProcessError: raise HTTPException( status_code=500, detail="Failed to execute the command.") @@ -63,10 +64,11 @@ async def run_inference(background_tasks: BackgroundTasks, payload: Payload): filename = f"{uuid4()}.png" # We will use background task to run the command so it won't block - background_tasks.add_task(run_command, payload, filename) + # background_tasks.add_task(run_command, payload, filename) + run_command(payload, filename) # Return the expected path of the output file - return {"url": f'/serve/{filename}'} + return {"url": f'{BASE_URL}/serve/{filename}'} @app.get("/serve/{filename}") From b9775c489344d7d0da35a0a343552dbd7896146e Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Wed, 30 Aug 2023 20:07:42 +0700 Subject: [PATCH 2/3] fix(docker): Update dockerfile for sd ggml api --- docker-compose.yml | 11 ++++++----- jan-inference/sd/inference.Dockerfile | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5b456f33e..757691320 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -190,15 +190,16 @@ services: dockerfile: inference.Dockerfile # Mount the directory that contains the downloaded model. volumes: - - ./jan-inference/sd/models:/models - - ./jan-inference/sd/output/:/serving/output + - ./jan-inference/sd/models:/models/ + - ./jan-inference/sd/output/:/output/ command: /bin/bash -c "python -m uvicorn main:app --proxy-headers --host 0.0.0.0 --port 8000" environment: # Specify the path to the model for the web application. - BASE_URL: http://0.0.0.0:8000 + BASE_URL: http://0.0.0.0:8001 MODEL_NAME: ${SD_MODEL_FILE}.q4_0.bin - MODEL_DIR: "/models" - SD_PATH: "/sd" + MODEL_DIR: /models + OUTPUT_DIR: /output + SD_PATH: /sd PYTHONUNBUFFERED: 1 ports: - 8001:8000 diff --git a/jan-inference/sd/inference.Dockerfile b/jan-inference/sd/inference.Dockerfile index 39d42dd43..db31e7f98 100644 --- a/jan-inference/sd/inference.Dockerfile +++ b/jan-inference/sd/inference.Dockerfile @@ -1,4 +1,6 @@ -FROM python:3.9.17 as build +ARG UBUNTU_VERSION=22.04 + +FROM ubuntu:$UBUNTU_VERSION as build RUN apt-get update && apt-get install -y build-essential git cmake From cbf33651c088bf398a0391c1b879897fdde8e9e8 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Wed, 30 Aug 2023 20:08:03 +0700 Subject: [PATCH 3/3] chore(inference): Update sd.cpp latest update --- jan-inference/sd/sd_cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jan-inference/sd/sd_cpp b/jan-inference/sd/sd_cpp index 0d7f04b13..c8f85a4e3 160000 --- a/jan-inference/sd/sd_cpp +++ b/jan-inference/sd/sd_cpp @@ -1 +1 @@ -Subproject commit 0d7f04b135cd48e8d62aecd09a52eb2afa482744 +Subproject commit c8f85a4e3063e2cdb27db57b8f6167da16453e0c