Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a sample integration for LLM models in huggingface #494

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/apps/hugging_face_integration_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM nvcr.io/nvidia/clara-holoscan/holoscan:v2.1.0-dgpu
MMelQin marked this conversation as resolved.
Show resolved Hide resolved
RUN pip install --upgrade pip
RUN pip install monai-deploy-app-sdk
RUN pip install transformers
RUN pip install hub
RUN pip install diffusers
RUN pip install torch
RUN pip install pydicom
RUN pip install accelerate
6 changes: 6 additions & 0 deletions examples/apps/hugging_face_integration_app/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
IMAGE=vikash112/monai-hugging:0.1.0
docker build -t $IMAGE .

monai_dir=/raid/Vikash/Tools/HUGGINGFACE/med_image_generation

NV_GPU=1 nvidia-docker run -it --rm --shm-size=4g --ulimit memlock=-1 --ulimit stack=67108864 -v $monai_dir:/workspace/app/test $IMAGE /bin/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import logging
from pathlib import Path
import torch
from diffusers import StableDiffusionPipeline
from monai.deploy.core import AppContext, Application
from PIL import Image
import numpy as np
import argparse



class App(Application):
name = "Diffusion Image App"
description = "Simple application showing diffusion to generate Images"
def compose(self):
model_id = "Nihirc/Prompt2MedImage"
MMelQin marked this conversation as resolved.
Show resolved Hide resolved
device = "cuda"
parser = argparse.ArgumentParser()
parser.add_argument("--input_prompt", type=str, default="Generate a X-ray")
parser.add_argument("--output", type=str, default="./out.jpg")
args = parser.parse_args()

input_prompt = args.input_prompt
output_path = args.output
print("Input Prompt: ", input_prompt)
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to(device)
prompt = "Show me an X ray pevic fracture"
image = pipe(prompt).images[0]
image.save(output_path)


if __name__ == "__main__":
logging.info(f"Begin {__name__}")
App().run()
logging.info(f"End {__name__}")



Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

python app.py --input_prompt "The patient had residual paralysis of the hand after poliomyelitis. It was necessary to stabilize the thumb with reference to the index finger. This was accomplished by placing a graft from the bone bank between the first and second metacarpals. The roentgenogram shows the complete healing of the graft one year later." --output out.jpg
Loading