From 9ac58edfdd5b0867b79dec36469e2f8266231e6c Mon Sep 17 00:00:00 2001 From: wangzg Date: Wed, 20 Dec 2023 17:56:51 +0800 Subject: [PATCH] fix: use get image (when comfyui api not available for user) add daemon/stop script for linux --- bin/creator_daemon.sh | 23 +++++++++++++++++++++++ bin/creator_stop.sh | 14 ++++++++++++++ modules/comfyflow.py | 6 ++++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 bin/creator_daemon.sh create mode 100644 bin/creator_stop.sh diff --git a/bin/creator_daemon.sh b/bin/creator_daemon.sh new file mode 100644 index 0000000..257e00e --- /dev/null +++ b/bin/creator_daemon.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# get current path +CUR_DIR="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")" +PROJECT_PATH=$(dirname $(dirname "$CUR_DIR")) +echo "$PROJECT_PATH" +cd $PROJECT_PATH + +# set LOGURU_LEVEL to ERROR +export LOGURU_LEVEL=INFO + +export STREAMLIT_SERVER_PORT=8501 +# set COMFYFLOW_API_URL to comfyflow api url +export COMFYFLOW_API_URL=https://api.comfyflow.app +# set COMFYUI_SERVER_ADDR to comfyui server addr +export COMFYUI_SERVER_ADDR=http://localhost:8188 +# set discord callback url +export DISCORD_REDIRECT_URI=http://localhost:8501 +# set MODE to Creator +export MODE=Creator + +# script params +nohup python -m streamlit run Home.py > app.log 2>&1 & \ No newline at end of file diff --git a/bin/creator_stop.sh b/bin/creator_stop.sh new file mode 100644 index 0000000..3d5c8a2 --- /dev/null +++ b/bin/creator_stop.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# 停止脚本 +APP_NAME="streamlit" + +# 查找并终止正在运行的 Flask 应用程序进程 +PID=$(ps aux | grep "$APP_NAME" | grep -v grep | awk '{print $2}') +if [ -n "$PID" ]; then + echo "Stopping $APP_NAME $PID..." + kill $PID + echo "Stoped $APP_NAME" +else + echo "$APP_NAME is not running." +fi \ No newline at end of file diff --git a/modules/comfyflow.py b/modules/comfyflow.py index 68f72c2..0c5eb8c 100644 --- a/modules/comfyflow.py +++ b/modules/comfyflow.py @@ -97,8 +97,10 @@ def get_outputs(self): if 'images' in node_output: images_output = [] for image in node_output['images']: - image_url = self.comfy_client.get_image_url(image['filename'], image['subfolder'], image['type']) - images_output.append(image_url) + # image_url = self.comfy_client.get_image_url(image['filename'], image['subfolder'], image['type']) + # images_output.append(image_url) + image_data = self.comfy_client.get_image(image['filename'], image['subfolder'], image['type']) + images_output.append(image_data) logger.info(f"Got images from server, {node_id}, {len(images_output)}") return 'images', images_output