-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
txt2img is just text2image component with ui. Add tracking to values file for searchqna and text2image in other repos. Signed-off-by: Dolpher Du <dolpher.du@intel.com>
- Loading branch information
1 parent
9d3d6d5
commit d271ecb
Showing
12 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v2 | ||
name: txt2img | ||
description: The Helm chart to deploy txt2img | ||
type: application | ||
dependencies: | ||
- name: text2image | ||
version: 0-latest | ||
repository: "file://../common/text2image" | ||
- name: ui | ||
version: 0-latest | ||
repository: "file://../common/ui" | ||
alias: txt2img-ui | ||
- name: nginx | ||
version: 0-latest | ||
repository: "file://../common/nginx" | ||
version: 0-latest | ||
appVersion: "v1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# txt2img | ||
|
||
Helm chart for deploying txt2img service. | ||
|
||
## Installing the Chart | ||
|
||
To install the chart, run the following: | ||
|
||
```console | ||
cd GenAIInfra/helm-charts/ | ||
./update_dependency.sh | ||
helm dependency update txt2img | ||
export HFTOKEN="insert-your-huggingface-token-here" | ||
export MODELDIR="/mnt/opea-models" | ||
# To run on Xeon | ||
helm install txt2img txt2img --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} | ||
# To run on Gaudi | ||
#helm install txt2img txt2img --set global.HUGGINGFACEHUB_API_TOKEN=${HFTOKEN} --set global.modelUseHostPath=${MODELDIR} -f txt2img/gaudi-values.yaml | ||
``` | ||
|
||
### IMPORTANT NOTE | ||
|
||
1. Make sure your `MODELDIR` exists on the node where your workload is schedueled so you can cache the downloaded model for next time use. Otherwise, set `global.modelUseHostPath` to 'null' if you don't want to cache the model. | ||
|
||
## Verify | ||
|
||
To verify the installation, run the command `kubectl get pod` to make sure all pods are running. | ||
|
||
Curl command and UI are the two options that can be leveraged to verify the result. | ||
|
||
### Verify the workload through curl command | ||
|
||
Then run the command `kubectl port-forward svc/txt2img-text2image 9379:9379` to expose the service for access. | ||
|
||
Open another terminal and run the following command to verify the service if working: | ||
|
||
```console | ||
curl http://localhost:9379/v1/text2image \ | ||
-XPOST \ | ||
-d '{"prompt":"An astronaut riding a green horse", "num_images_per_prompt":1}' \ | ||
-H 'Content-Type: application/json' | ||
``` | ||
|
||
### Verify the workload through UI | ||
|
||
The UI has already been installed via the Helm chart. To access it, use the external IP of one your Kubernetes node along with the NGINX port. You can find the NGINX port using the following command: | ||
|
||
```bash | ||
export port=$(kubectl get service txt2img-nginx --output='jsonpath={.spec.ports[0].nodePort}') | ||
echo $port | ||
``` | ||
|
||
Open a browser to access `http://<k8s-node-ip-address>:${port}` to play with the txt2img workload. | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
| ---------------- | ------ | ----------------------------------------------- | ------------------------------------------------------------------------ | | ||
| text2image.MODEL | string | `"stable-diffusion-v1-5/stable-diffusion-v1-5"` | Models id from https://huggingface.co/, or predownloaded model directory | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
text2image: | ||
image: | ||
repository: opea/text2image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
text2image: | ||
accelDevice: "gaudi" | ||
image: | ||
repository: opea/text2image-gaudi | ||
tag: "latest" | ||
resources: | ||
limits: | ||
habana.ai/gaudi: 1 | ||
# The following hugepage related settings is for default MODEL stable-diffusion-v1-5/stable-diffusion-v1-5 | ||
# User should change the resource limits for other models | ||
hugepages-2Mi: 256Mi | ||
volumes: | ||
- name: hugepage-2mi | ||
emptyDir: | ||
medium: HugePages-2Mi | ||
volumeMounts: | ||
- name: hugepage-2mi | ||
mountPath: /hugepages-2Mi | ||
OMPI_MCA_btl_vader_single_copy_mechanism: "none" | ||
readinessProbe: | ||
initialDelaySeconds: 5 | ||
periodSeconds: 5 | ||
timeoutSeconds: 1 | ||
startupProbe: | ||
initialDelaySeconds: 5 | ||
periodSeconds: 5 | ||
timeoutSeconds: 1 | ||
failureThreshold: 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "txt2img.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "txt2img.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "txt2img.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "txt2img.labels" -}} | ||
helm.sh/chart: {{ include "txt2img.chart" . }} | ||
{{ include "txt2img.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "txt2img.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "txt2img.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "txt2img.serviceAccountName" -}} | ||
{{- if .Values.global.sharedSAName }} | ||
{{- .Values.global.sharedSAName }} | ||
{{- else if .Values.serviceAccount.create }} | ||
{{- default (include "txt2img.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Release.Name }}-nginx-config | ||
labels: | ||
{{- include "txt2img.labels" . | nindent 4 }} | ||
data: | ||
FRONTEND_SERVICE_IP: {{ include "ui.fullname" (index .Subcharts "txt2img-ui") | quote }} | ||
FRONTEND_SERVICE_PORT: {{ index .Values "txt2img-ui" "service" "port" | quote }} | ||
BACKEND_SERVICE_NAME: text2image | ||
BACKEND_SERVICE_IP: {{ include "txt2img.fullname" (index .Subcharts "text2image") | quote }} | ||
BACKEND_SERVICE_PORT: {{ .Values.text2image.service.port | quote }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
{{- if .Values.serviceAccount.create }} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "txt2img.serviceAccountName" . }} | ||
labels: | ||
{{- include "txt2img.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
automountServiceAccountToken: {{ .Values.serviceAccount.automount }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "txt2img.fullname" . }}-testpod" | ||
labels: | ||
{{- include "txt2img.labels" . | nindent 4 }} | ||
annotations: | ||
"helm.sh/hook": test | ||
spec: | ||
containers: | ||
- name: curl | ||
image: python:3.10 | ||
command: ['bash', '-c'] | ||
args: | ||
- | | ||
max_retry=20; | ||
for ((i=1; i<=max_retry; i++)); do | ||
curl http://{{ include "txt2img.fullname" (index .Subcharts "text2image") }}:{{ .Values.text2image.service.port }}/v1/text2image -sS --fail-with-body \ | ||
-X POST \ | ||
-d '{"prompt":"An astronaut riding a green horse", "num_images_per_prompt":1}' \ | ||
-H 'Content-Type: application/json' && break; | ||
curlcode=$? | ||
if [[ $curlcode -eq 7 ]]; then sleep 10; else echo "curl failed with code $curlcode"; exit 1; fi; | ||
done; | ||
if [ $i -gt $max_retry ]; then echo "test failed with maximum retry"; exit 1; fi | ||
restartPolicy: Never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Default values for txt2img. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
nginx: | ||
service: | ||
type: NodePort | ||
|
||
txt2img-ui: | ||
image: | ||
repository: opea/text2image-ui | ||
tag: "latest" | ||
BACKEND_SERVICE_ENDPOINT: "/v1/text2image" | ||
containerPort: 5173 | ||
|
||
serviceAccount: | ||
# Specifies whether a service account should be created | ||
create: true | ||
# Automatically mount a ServiceAccount's API credentials? | ||
automount: true | ||
# Annotations to add to the service account | ||
annotations: {} | ||
# The name of the service account to use. | ||
# If not set and create is true, a name is generated using the fullname template | ||
name: "" | ||
|
||
global: | ||
http_proxy: "" | ||
https_proxy: "" | ||
no_proxy: "" | ||
HUGGINGFACEHUB_API_TOKEN: "insert-your-huggingface-token-here" | ||
# service account name to be shared with all parent/child charts. | ||
# If set, it will overwrite serviceAccount.name. | ||
# If set, and serviceAccount.create is false, it will assume this service account is already created by others. | ||
sharedSAName: "txt2img" | ||
# set modelUseHostPath or modelUsePVC to use model cache. | ||
modelUseHostPath: "" | ||
# modelUseHostPath: /mnt/opea-models | ||
# modelUsePVC: model-volume | ||
|
||
# Install Prometheus serviceMonitors for service components | ||
monitoring: false | ||
|
||
# Prometheus Helm install release name needed for serviceMonitors | ||
prometheusRelease: prometheus-stack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters