-
Notifications
You must be signed in to change notification settings - Fork 446
Add usage snippets for Google Health AI models #1084
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
67a3e17
Add CXR Foundation and Derm Foundation model libraries (Google Health…
ndebuhr d02c152
Implement the PR review suggestion for Derm Foundation repo name casing
ndebuhr a9dc7dc
Implement the PR review suggestion for CXR Foundation repo name casing
ndebuhr 1560b82
Add model library usage snippets to the CXR Foundation and Derm Found…
ndebuhr 1e841b1
Merge branch 'main' of github.com:huggingface/huggingface.js into goo…
ndebuhr 4f24453
Merge branch 'main' of github.com:huggingface/huggingface.js into goo…
ndebuhr f31df49
Remove the CXR Foundation model library snippet
ndebuhr 719c7af
Simplify the Derm Foundation model library usage snippet - focus on i…
ndebuhr c4d3af3
Add a new usage snippet for the CXR Foundation model library, which u…
ndebuhr 4809837
Merge branch 'main' of github.com:huggingface/huggingface.js into goo…
ndebuhr fa66830
Trim down the Derm Foundation usage snippet comments
ndebuhr 60a89d5
Apply suggestions from code review
Wauplin fa5cead
Merge branch 'main' of github.com:huggingface/huggingface.js into goo…
ndebuhr 35dc73a
Update Derm and CXR snippets to the latest state of feedback/discussions
ndebuhr ec71e2f
Merge branch 'main' into google-hai-libraries
Wauplin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -95,6 +95,29 @@ export const bm25s = (model: ModelData): string[] => [ | |
retriever = BM25HF.load_from_hub("${model.id}")`, | ||
]; | ||
|
||
export const cxr_foundation = (model: ModelData): string[] => [ | ||
`!git clone https://github.com/Google-Health/cxr-foundation.git | ||
import tensorflow as tf, sys, requests | ||
sys.path.append('cxr-foundation/python/') | ||
|
||
# Install dependencies | ||
major_version = tf.__version__.rsplit(".", 1)[0] | ||
!pip install tensorflow-text=={major_version} pypng && pip install --no-deps pydicom hcls_imaging_ml_toolkit retrying | ||
Comment on lines
+99
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still a bit sad to have these installation steps in the "run this model" snippet. Any way we can link to some external documentation instead of this snippet is the only official snippet we can find on the internet? |
||
|
||
# Load image (Stillwaterising, CC0, via Wikimedia Commons) | ||
from PIL import Image | ||
from io import BytesIO | ||
image_url = "https://upload.wikimedia.org/wikipedia/commons/c/c8/Chest_Xray_PA_3-8-2010.png" | ||
response = requests.get(image_url, headers={'User-Agent': 'Demo'}, stream=True) | ||
response.raw.decode_content = True # Ensure correct decoding | ||
img = Image.open(BytesIO(response.content)).convert('L') # Convert to grayscale | ||
|
||
# Run inference | ||
from clientside.clients import make_hugging_face_client | ||
cxr_client = make_hugging_face_client('cxr_model') | ||
print(cxr_client.get_image_embeddings_from_images([img]))`, | ||
]; | ||
|
||
export const depth_anything_v2 = (model: ModelData): string[] => { | ||
let encoder: string; | ||
let features: string; | ||
|
@@ -168,6 +191,28 @@ focallength_px = prediction["focallength_px"]`; | |
return [installSnippet, inferenceSnippet]; | ||
}; | ||
|
||
export const derm_foundation = (model: ModelData): string[] => [ | ||
ndebuhr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`from huggingface_hub import from_pretrained_keras | ||
import tensorflow as tf, requests | ||
|
||
# Load and format input | ||
IMAGE_URL = "https://storage.googleapis.com/dx-scin-public-data/dataset/images/3445096909671059178.png" | ||
input_tensor = tf.train.Example( | ||
features=tf.train.Features( | ||
feature={ | ||
"image/encoded": tf.train.Feature( | ||
bytes_list=tf.train.BytesList(value=[requests.get(IMAGE_URL, stream=True).content]) | ||
) | ||
} | ||
) | ||
).SerializeToString() | ||
|
||
# Load model and run inference | ||
loaded_model = from_pretrained_keras("google/derm-foundation") | ||
infer = loaded_model.signatures["serving_default"] | ||
print(infer(inputs=tf.constant([input_tensor])))`, | ||
] | ||
|
||
const diffusersDefaultPrompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"; | ||
|
||
const diffusers_default = (model: ModelData) => [ | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.