[diffusion] chore: minor improvements and typo-fixing (#15556)
This commit is contained in:
@@ -1,17 +1,22 @@
|
|||||||
# SGLang Diffusion WebUI User Guide
|
# SGLang Diffusion WebUI User Guide
|
||||||
|
|
||||||
SGLang Diffusion WebUI provides an intuitive Gradio-based interface for image and video generation, supporting parameter tuning and real-time previews.
|
SGLang Diffusion WebUI provides an intuitive Gradio-based interface for image and video generation, supporting parameter
|
||||||
|
tuning and real-time previews.
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
The WebUI runs on Gradio. To get started, install Gradio first:
|
The WebUI runs on Gradio. To get started, install Gradio first:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install gradio==6.1.0
|
pip install gradio==6.1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Launch WebUI Service
|
## Launch WebUI Service
|
||||||
|
|
||||||
SGLang Diffusion now includes an integrated WebUI. Simply add the `--webui` parameter when starting the service.
|
SGLang Diffusion now includes an integrated WebUI. Simply add the `--webui` parameter when starting the service.
|
||||||
|
|
||||||
### Launch Text-to-Image Service
|
### Launch Text-to-Image Service
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
SERVER_ARGS=(
|
SERVER_ARGS=(
|
||||||
--model-path black-forest-labs/FLUX.1-dev
|
--model-path black-forest-labs/FLUX.1-dev
|
||||||
@@ -20,7 +25,9 @@ SERVER_ARGS=(
|
|||||||
WEBUI_PORT=2333
|
WEBUI_PORT=2333
|
||||||
sglang serve "${SERVER_ARGS[@]}" --webui --webui-port ${WEBUI_PORT}
|
sglang serve "${SERVER_ARGS[@]}" --webui --webui-port ${WEBUI_PORT}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Launch Text-to-Video Service
|
### Launch Text-to-Video Service
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
SERVER_ARGS=(
|
SERVER_ARGS=(
|
||||||
--model-path Wan-AI/Wan2.2-T2V-A14B-Diffusers
|
--model-path Wan-AI/Wan2.2-T2V-A14B-Diffusers
|
||||||
@@ -31,15 +38,18 @@ sglang serve "${SERVER_ARGS[@]}" --webui --webui-port ${WEBUI_PORT}
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Port Forwarding
|
## Port Forwarding
|
||||||
Once the WebUI service is running, you need to use **SSH port forwarding** to securely access the remote service from your local machine.
|
|
||||||
|
|
||||||
In most cases: Your IDE (like VS Code, Cursor, etc.) can handle this automatically. Check your IDE's remote development or port forwarding features. Otherwise, execute this command manually.
|
Once the WebUI service is running, you need to use **SSH port forwarding** to securely access the remote service from
|
||||||
|
your local machine.
|
||||||
|
|
||||||
|
In most cases: Your IDE (like VS Code, Cursor, etc.) can handle this automatically. Check your IDE's remote development
|
||||||
|
or port forwarding features. Otherwise, execute this command manually.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ssh -L ${WEBUI_PORT}:localhost:${WEBUI_PORT} user_name@machine_name
|
ssh -L ${WEBUI_PORT}:localhost:${WEBUI_PORT} user_name@machine_name
|
||||||
```
|
```
|
||||||
Learn more about port forwarding: [Port Forwarding](https://en.wikipedia.org/wiki/Port_forwarding).
|
|
||||||
|
|
||||||
|
Learn more about port forwarding: [Port Forwarding](https://en.wikipedia.org/wiki/Port_forwarding).
|
||||||
|
|
||||||
## Interface Instructions
|
## Interface Instructions
|
||||||
|
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ class DiffGenerator:
|
|||||||
sample,
|
sample,
|
||||||
fps=req.fps,
|
fps=req.fps,
|
||||||
save_output=req.save_output,
|
save_output=req.save_output,
|
||||||
|
# TODO: output file path for req should be determined
|
||||||
save_file_path=req.output_file_path(
|
save_file_path=req.output_file_path(
|
||||||
num_outputs, output_idx
|
num_outputs, output_idx
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ def post_process_sample(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
imageio.imwrite(save_file_path, frames[0])
|
imageio.imwrite(save_file_path, frames[0])
|
||||||
logger.info(f"Saved output to {CYAN}{save_file_path}{RESET}")
|
logger.info(f"Output saved to {CYAN}{save_file_path}{RESET}")
|
||||||
else:
|
else:
|
||||||
logger.info(f"No output path provided, output not saved")
|
logger.info(f"No output path provided, output not saved")
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def run_pytest(files, filter_expr=None):
|
|||||||
print("No files to run.")
|
print("No files to run.")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
base_cmd = [sys.executable, "-m", "pytest", "-s", "-v", "--log-cli-level=INFO"]
|
base_cmd = [sys.executable, "-m", "pytest", "-s", "-v"]
|
||||||
|
|
||||||
# Add pytest -k filter if provided
|
# Add pytest -k filter if provided
|
||||||
if filter_expr:
|
if filter_expr:
|
||||||
@@ -124,20 +124,20 @@ def run_pytest(files, filter_expr=None):
|
|||||||
cmd,
|
cmd,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
text=True,
|
bufsize=0,
|
||||||
bufsize=1,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
output_lines = []
|
output_bytes = bytearray()
|
||||||
while True:
|
while True:
|
||||||
line = process.stdout.readline()
|
chunk = process.stdout.read(4096)
|
||||||
if not line and process.poll() is not None:
|
if not chunk:
|
||||||
break
|
break
|
||||||
if line:
|
sys.stdout.buffer.write(chunk)
|
||||||
sys.stdout.write(line)
|
sys.stdout.buffer.flush()
|
||||||
output_lines.append(line)
|
output_bytes.extend(chunk)
|
||||||
|
|
||||||
returncode = process.poll()
|
process.wait()
|
||||||
|
returncode = process.returncode
|
||||||
|
|
||||||
if returncode == 0:
|
if returncode == 0:
|
||||||
return 0
|
return 0
|
||||||
@@ -152,7 +152,7 @@ def run_pytest(files, filter_expr=None):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# check if the failure is due to an assertion in test_server_utils.py
|
# check if the failure is due to an assertion in test_server_utils.py
|
||||||
full_output = "".join(output_lines)
|
full_output = output_bytes.decode("utf-8", errors="replace")
|
||||||
is_perf_assertion = (
|
is_perf_assertion = (
|
||||||
"multimodal_gen/test/server/test_server_utils.py" in full_output
|
"multimodal_gen/test/server/test_server_utils.py" in full_output
|
||||||
and "AssertionError" in full_output
|
and "AssertionError" in full_output
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ class ServerManager:
|
|||||||
with pipe:
|
with pipe:
|
||||||
for line in iter(pipe.readline, ""):
|
for line in iter(pipe.readline, ""):
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
|
sys.stdout.flush()
|
||||||
file.write(line)
|
file.write(line)
|
||||||
file.flush()
|
file.flush()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -360,6 +361,8 @@ class ServerManager:
|
|||||||
"""Wait for server to become ready."""
|
"""Wait for server to become ready."""
|
||||||
start = time.time()
|
start = time.time()
|
||||||
ready_message = "Application startup complete."
|
ready_message = "Application startup complete."
|
||||||
|
log_period = 30
|
||||||
|
prev_log_period_count = 0
|
||||||
|
|
||||||
while time.time() - start < self.wait_deadline:
|
while time.time() - start < self.wait_deadline:
|
||||||
if process.poll() is not None:
|
if process.poll() is not None:
|
||||||
@@ -378,8 +381,10 @@ class ServerManager:
|
|||||||
logger.debug("Could not read log yet: %s", e)
|
logger.debug("Could not read log yet: %s", e)
|
||||||
|
|
||||||
elapsed = int(time.time() - start)
|
elapsed = int(time.time() - start)
|
||||||
|
if (elapsed // log_period) > prev_log_period_count:
|
||||||
|
prev_log_period_count = elapsed // log_period
|
||||||
logger.info("[server-test] Waiting for server... elapsed=%ss", elapsed)
|
logger.info("[server-test] Waiting for server... elapsed=%ss", elapsed)
|
||||||
time.sleep(5)
|
time.sleep(1)
|
||||||
|
|
||||||
tail = self._get_log_tail(stdout_path)
|
tail = self._get_log_tail(stdout_path)
|
||||||
raise TimeoutError(f"Server not ready within {self.wait_deadline}s.\n{tail}")
|
raise TimeoutError(f"Server not ready within {self.wait_deadline}s.\n{tail}")
|
||||||
|
|||||||
Reference in New Issue
Block a user