Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavs10 committed Oct 16, 2023
1 parent 944ca1f commit 253495c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions js/src/lib/inferenceSnippets/servePython.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ from PIL import Image
image = Image.open(io.BytesIO(image_bytes))`;

export const snippetTextToAudio = (model: ModelData): string => {
if (ModelData.library_name === "transformers") {
return `def query(payload):
if (ModelData.library_name === "transformers") {
return `def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
audio_bytes = query({
Expand All @@ -53,17 +53,17 @@ audio_bytes = query({
# You can access the audio with IPython.display for example
from IPython.display import Audio
Audio(audio_bytes)`
}else{
return `def query(payload):
Audio(audio_bytes)`;
} else {
return `def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": ${getModelInputSnippet(model)},
})`
}
}
})`;
}
};
export const pythonSnippets: Partial<Record<PipelineType, (model: ModelData) => string>> = {
// Same order as in js/src/lib/interfaces/Types.ts
"text-classification": snippetBasic,
Expand All @@ -83,7 +83,7 @@ export const pythonSnippets: Partial<Record<PipelineType, (model: ModelData) =>
"text-to-image": snippetTextToImage,
"text-to-speech": snippetTextToAudio,
"text-to-audio": snippetTextToAudio,
"audio-to-audio": snippetFile,
"audio-to-audio": snippetFile,
"audio-classification": snippetFile,
"image-classification": snippetFile,
"image-to-text": snippetFile,
Expand Down

0 comments on commit 253495c

Please sign in to comment.