Skip to content

Commit ca5e286

Browse files
poojak13Ashwin Krishna
authored andcommitted
Making Jumpstart notebooks Python 3.10 compatible (#269)
1 parent 7fbef2d commit ca5e286

File tree

16 files changed

+42
-42
lines changed

16 files changed

+42
-42
lines changed

inference/generativeai/llm-workshop/lab2-stable-diffusion/option1-jumpstart/Amazon_JumpStart_Text_To_Image.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
},
9797
"outputs": [],
9898
"source": [
99-
"!pip install ipywidgets==7.0.0 --quiet"
99+
"!pip install ipywidgets --quiet"
100100
]
101101
},
102102
{
@@ -173,15 +173,15 @@
173173
},
174174
"outputs": [],
175175
"source": [
176-
"from ipywidgets import Dropdown\n",
176+
"import ipywidgets as widgets\n",
177177
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
178178
"\n",
179179
"# Retrieves all Text-to-Image generation models.\n",
180180
"filter_value = \"task == txt2img\"\n",
181181
"txt2img_models = list_jumpstart_models(filter=filter_value)\n",
182182
"\n",
183183
"# display the model-ids in a dropdown to select a model for inference.\n",
184-
"model_dropdown = Dropdown(\n",
184+
"model_dropdown = widgets.Dropdown(\n",
185185
" options=txt2img_models,\n",
186186
" value=\"model-txt2img-stabilityai-stable-diffusion-v2-fp16\",\n",
187187
" description=\"Select a model\",\n",
@@ -528,7 +528,7 @@
528528
"---\n",
529529
"Writing a good prompt can sometime be an art. It is often difficult to predict whether a certain prompt will yield a satisfactory image with a given model. However, there are certain templates that have been observed to work. Broadly, a prompt can be roughly broken down into three pieces: (i) type of image (photograph/sketch/painting etc.), (ii) description (subject/object/environment/scene etc.) and (iii) the style of the image (realistic/artistic/type of art etc.). You can change each of the three parts individually to generate variations of an image. Adjectives have been known to play a significant role in the image generation process. Also, adding more details help in the generation process.\n",
530530
"\n",
531-
"To generate a realistic image, you can use phrases such as \u201ca photo of\u201d, \u201ca photograph of\u201d, \u201crealistic\u201d or \u201chyper realistic\u201d. To generate images by artists you can use phrases like \u201cby Pablo Piccaso\u201d or \u201coil painting by Rembrandt\u201d or \u201clandscape art by Frederic Edwin Church\u201d or \u201cpencil drawing by Albrecht D\u00fcrer\u201d. You can also combine different artists as well. To generate artistic image by category, you can add the art category in the prompt such as \u201clion on a beach, abstract\u201d. Some other categories include \u201coil painting\u201d, \u201cpencil drawing, \u201cpop art\u201d, \u201cdigital art\u201d, \u201canime\u201d, \u201ccartoon\u201d, \u201cfuturism\u201d, \u201cwatercolor\u201d, \u201cmanga\u201d etc. You can also include details such as lighting or camera lens such as 35mm wide lens or 85mm wide lens and details about the framing (portrait/landscape/close up etc.).\n",
531+
"To generate a realistic image, you can use phrases such as “a photo of”, “a photograph of”, “realistic” or “hyper realistic. To generate images by artists you can use phrases like “by Pablo Piccaso or “oil painting by Rembrandt or “landscape art by Frederic Edwin Church or “pencil drawing by Albrecht Dürer”. You can also combine different artists as well. To generate artistic image by category, you can add the art category in the prompt such as “lion on a beach, abstract. Some other categories include “oil painting”, “pencil drawing, “pop art”, “digital art”, “anime”, “cartoon”, “futurism”, “watercolor”, “manga” etc. You can also include details such as lighting or camera lens such as 35mm wide lens or 85mm wide lens and details about the framing (portrait/landscape/close up etc.).\n",
532532
"\n",
533533
"Note that model generates different images even if same prompt is given multiple times. So, you can generate multiple images and select the image that suits your application best.\n",
534534
"\n",
@@ -1167,4 +1167,4 @@
11671167
},
11681168
"nbformat": 4,
11691169
"nbformat_minor": 5
1170-
}
1170+
}

introduction_to_amazon_algorithms/image_classification_tensorflow/Amazon_TensorFlow_Image_Classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"outputs": [],
156156
"source": [
157157
"import IPython\n",
158-
"from ipywidgets import Dropdown\n",
158+
"import ipywidgets as widgets\n",
159159
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
160160
"from sagemaker.jumpstart.filters import And\n",
161161
"\n",
@@ -164,7 +164,7 @@
164164
"ic_models = list_jumpstart_models(filter=filter_value)\n",
165165
"\n",
166166
"# display the model-ids in a dropdown, for user to select a model.\n",
167-
"dropdown = Dropdown(\n",
167+
"dropdown = widgets.Dropdown(\n",
168168
" options=ic_models,\n",
169169
" value=model_id,\n",
170170
" description=\"SageMaker Built-In TensorFlow Image Classification Models:\",\n",

introduction_to_amazon_algorithms/jumpstart-foundation-models/automatic-speech-recognition.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@
130130
"outputs": [],
131131
"source": [
132132
"import IPython\n",
133-
"from ipywidgets import Dropdown\n",
133+
"import ipywidgets as widgets\n",
134134
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
135135
"from sagemaker.jumpstart.filters import And\n",
136136
"\n",
137137
"\n",
138138
"filter_value = And(\"task == asr\", \"framework == huggingface\")\n",
139139
"asr_models = list_jumpstart_models(filter=filter_value)\n",
140140
"\n",
141-
"dropdown = Dropdown(\n",
141+
"dropdown = widgets.Dropdown(\n",
142142
" value=model_id,\n",
143143
" options=asr_models,\n",
144144
" description=\"Sagemaker Pre-Trained Automatic Speech Recognition Models:\",\n",

introduction_to_amazon_algorithms/jumpstart-foundation-models/text-generation-falcon.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"outputs": [],
4848
"source": [
4949
"!pip install sagemaker --quiet --upgrade --force-reinstall\n",
50-
"!pip install ipywidgets==7.0.0 --quiet"
50+
"!pip install ipywidgets --quiet"
5151
]
5252
},
5353
{
@@ -81,7 +81,7 @@
8181
},
8282
"outputs": [],
8383
"source": [
84-
"from ipywidgets import Dropdown\n",
84+
"import ipywidgets as widgets\n",
8585
"\n",
8686
"model_ids = [\n",
8787
" \"huggingface-llm-falcon-40b-bf16\",\n",
@@ -91,7 +91,7 @@
9191
"]\n",
9292
"\n",
9393
"# display the model-ids in a dropdown to select a model for inference.\n",
94-
"model_dropdown = Dropdown(\n",
94+
"model_dropdown = widgets.Dropdown(\n",
9595
" options=model_ids,\n",
9696
" value=model_id,\n",
9797
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart-foundation-models/text2text-generation-bloomz.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
},
104104
"outputs": [],
105105
"source": [
106-
"!pip install ipywidgets==7.0.0 --quiet\n",
106+
"!pip install ipywidgets --quiet\n",
107107
"!pip install --upgrade sagemaker --quiet"
108108
]
109109
},
@@ -186,15 +186,15 @@
186186
},
187187
"outputs": [],
188188
"source": [
189-
"from ipywidgets import Dropdown\n",
189+
"import ipywidgets as widgets\n",
190190
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
191191
"\n",
192192
"# Retrieves all Text Generation models available by SageMaker Built-In Algorithms.\n",
193193
"filter_value = \"task == textgeneration1\"\n",
194194
"text_generation_models = list_jumpstart_models(filter=filter_value)\n",
195195
"\n",
196196
"# display the model-ids in a dropdown to select a model for inference.\n",
197-
"model_dropdown = Dropdown(\n",
197+
"model_dropdown = widgets.Dropdown(\n",
198198
" options=text_generation_models,\n",
199199
" value=model_id,\n",
200200
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart-foundation-models/text2text-generation-flan-t5-ul2.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"!pip install ipywidgets==7.0.0 --quiet\n",
100+
"!pip install ipywidgets --quiet\n",
101101
"!pip install --upgrade sagemaker --quiet"
102102
]
103103
},
@@ -180,15 +180,15 @@
180180
},
181181
"outputs": [],
182182
"source": [
183-
"from ipywidgets import Dropdown\n",
183+
"import ipywidgets as widgets\n",
184184
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
185185
"\n",
186186
"# Retrieves all Text Generation models available by SageMaker Built-In Algorithms.\n",
187187
"filter_value = \"task == text2text\"\n",
188188
"text_generation_models = list_jumpstart_models(filter=filter_value)\n",
189189
"\n",
190190
"# display the model-ids in a dropdown to select a model for inference.\n",
191-
"model_dropdown = Dropdown(\n",
191+
"model_dropdown = widgets.Dropdown(\n",
192192
" options=text_generation_models,\n",
193193
" value=model_id,\n",
194194
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart-foundation-models/text2text-generation-flan-t5.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"!pip install ipywidgets==7.0.0 --quiet\n",
100+
"!pip install ipywidgets --quiet\n",
101101
"!pip install --upgrade sagemaker --quiet"
102102
]
103103
},
@@ -149,15 +149,15 @@
149149
},
150150
"outputs": [],
151151
"source": [
152-
"from ipywidgets import Dropdown\n",
152+
"import ipywidgets as widgets\n",
153153
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
154154
"\n",
155155
"# Retrieves all Text Generation models available by SageMaker Built-In Algorithms.\n",
156156
"filter_value = \"task == text2text\"\n",
157157
"text_generation_models = list_jumpstart_models(filter=filter_value)\n",
158158
"\n",
159159
"# display the model-ids in a dropdown to select a model for inference.\n",
160-
"model_dropdown = Dropdown(\n",
160+
"model_dropdown = widgets.Dropdown(\n",
161161
" options=text_generation_models,\n",
162162
" value=model_id,\n",
163163
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart_image_classification/Amazon_JumpStart_Image_Classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"outputs": [],
156156
"source": [
157157
"import IPython\n",
158-
"from ipywidgets import Dropdown\n",
158+
"import ipywidgets as widgets\n",
159159
"\n",
160160
"# download JumpStart model_manifest file.\n",
161161
"boto3.client(\"s3\").download_file(\n",
@@ -171,7 +171,7 @@
171171
"[ic_models.append(model) for model in ic_models_all_versions if model not in ic_models]\n",
172172
"\n",
173173
"# display the model-ids in a dropdown, for user to select a model.\n",
174-
"dropdown = Dropdown(\n",
174+
"dropdown = widgets.Dropdown(\n",
175175
" options=ic_models,\n",
176176
" value=model_id,\n",
177177
" description=\"JumpStart Image Classification Models:\",\n",

introduction_to_amazon_algorithms/jumpstart_question_answering/Amazon_JumpStart_Question_Answering.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
"outputs": [],
156156
"source": [
157157
"import IPython\n",
158-
"from ipywidgets import Dropdown\n",
158+
"import ipywidgets as widgets\n",
159159
"\n",
160160
"# download JumpStart model_manifest file.\n",
161161
"boto3.client(\"s3\").download_file(\n",
@@ -171,7 +171,7 @@
171171
"[eqa_models.append(model) for model in eqa_models_all_versions if model not in eqa_models]\n",
172172
"\n",
173173
"# display the model-ids in a dropdown, for user to select a model.\n",
174-
"dropdown = Dropdown(\n",
174+
"dropdown = widgets.Dropdown(\n",
175175
" value=model_id,\n",
176176
" options=eqa_models,\n",
177177
" description=\"JumpStart Extractive Question Answering Models:\",\n",

introduction_to_amazon_algorithms/jumpstart_sentence_pair_classification/Amazon_JumpStart_Sentence_Pair_Classification.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"outputs": [],
149149
"source": [
150150
"import IPython\n",
151-
"from ipywidgets import Dropdown\n",
151+
"import ipywidgets as widgets\n",
152152
"\n",
153153
"# download JumpStart model_manifest file.\n",
154154
"boto3.client(\"s3\").download_file(\n",
@@ -164,7 +164,7 @@
164164
"[spc_models.append(model) for model in spc_models_all_versions if model not in spc_models]\n",
165165
"\n",
166166
"# display the model-ids in a dropdown, for user to select a model.\n",
167-
"dropdown = Dropdown(\n",
167+
"dropdown = widgets.Dropdown(\n",
168168
" value=model_id,\n",
169169
" options=spc_models,\n",
170170
" description=\"JumpStart Sentence Pair Classification Models:\",\n",

introduction_to_amazon_algorithms/jumpstart_text_classification/Amazon_JumpStart_HuggingFace_Text_Classification.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"metadata": {},
8888
"outputs": [],
8989
"source": [
90-
"!pip install ipywidgets==7.0.0 --quiet"
90+
"!pip install ipywidgets --quiet"
9191
]
9292
},
9393
{
@@ -147,15 +147,15 @@
147147
"outputs": [],
148148
"source": [
149149
"import IPython\n",
150-
"from ipywidgets import Dropdown\n",
150+
"import ipywidgets as widgets\n",
151151
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
152152
"from sagemaker.jumpstart.filters import And\n",
153153
"\n",
154154
"# Retrieves all Text Classification models available by SageMaker Built-In Algorithms.\n",
155155
"filter_value = And(\"task == tc\", \"framework == huggingface\")\n",
156156
"tc_models = list_jumpstart_models(filter=filter_value)\n",
157157
"# display the model-ids in a dropdown, for user to select a model.\n",
158-
"dropdown = Dropdown(\n",
158+
"dropdown = widgets.Dropdown(\n",
159159
" value=model_id,\n",
160160
" options=tc_models,\n",
161161
" description=\"Sagemaker Pre-Trained Text Classification Models:\",\n",

introduction_to_amazon_algorithms/jumpstart_text_generation/Amazon_JumpStart_Text_Generation.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"metadata": {},
162162
"outputs": [],
163163
"source": [
164-
"from ipywidgets import Dropdown\n",
164+
"import ipywidgets as widgets\n",
165165
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
166166
"from sagemaker.jumpstart.filters import And\n",
167167
"\n",
@@ -170,7 +170,7 @@
170170
"text_generation_models = list_jumpstart_models(filter=filter_value)\n",
171171
"\n",
172172
"# display the model-ids in a dropdown to select a model for inference.\n",
173-
"model_dropdown = Dropdown(\n",
173+
"model_dropdown = widgets.Dropdown(\n",
174174
" options=text_generation_models,\n",
175175
" value=model_id,\n",
176176
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart_text_summarization/Amazon_JumpStart_Text_Summarization.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"metadata": {},
133133
"outputs": [],
134134
"source": [
135-
"from ipywidgets import Dropdown\n",
135+
"import ipywidgets as widgets\n",
136136
"\n",
137137
"# download JumpStart model_manifest file.\n",
138138
"boto3.client(\"s3\").download_file(\n",
@@ -149,7 +149,7 @@
149149
" text_summarization_models.append(model_id)\n",
150150
"\n",
151151
"# display the model-ids in a dropdown to select a model for inference.\n",
152-
"model_dropdown = Dropdown(\n",
152+
"model_dropdown = widgets.Dropdown(\n",
153153
" options=text_summarization_models,\n",
154154
" value=\"huggingface-summarization-distilbart-cnn-6-6\",\n",
155155
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart_text_to_image/Amazon_JumpStart_Text_To_Image.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
},
110110
"outputs": [],
111111
"source": [
112-
"!pip install ipywidgets==7.0.0 --quiet\n",
112+
"!pip install ipywidgets --quiet\n",
113113
"!pip install --upgrade sagemaker"
114114
]
115115
},
@@ -177,15 +177,15 @@
177177
},
178178
"outputs": [],
179179
"source": [
180-
"from ipywidgets import Dropdown\n",
180+
"import ipywidgets as widgets\n",
181181
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
182182
"\n",
183183
"# Retrieves all Text-to-Image generation models.\n",
184184
"filter_value = \"task == txt2img\"\n",
185185
"txt2img_models = list_jumpstart_models(filter=filter_value)\n",
186186
"\n",
187187
"# display the model-ids in a dropdown to select a model for inference.\n",
188-
"model_dropdown = Dropdown(\n",
188+
"model_dropdown = widgets.Dropdown(\n",
189189
" options=txt2img_models,\n",
190190
" value=\"model-txt2img-stabilityai-stable-diffusion-v2-1-base\",\n",
191191
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/jumpstart_text_to_image/JumpStart_Stable_Diffusion_Inference_Only.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"outputs": [],
9999
"source": [
100-
"!pip install ipywidgets==7.0.0 --quiet"
100+
"!pip install ipywidgets --quiet"
101101
]
102102
},
103103
{
@@ -174,15 +174,15 @@
174174
},
175175
"outputs": [],
176176
"source": [
177-
"from ipywidgets import Dropdown\n",
177+
"import ipywidgets as widgets\n",
178178
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
179179
"\n",
180180
"# Retrieves all Text-to-Image generation models.\n",
181181
"filter_value = \"task == txt2img\"\n",
182182
"txt2img_models = list_jumpstart_models(filter=filter_value)\n",
183183
"\n",
184184
"# display the model-ids in a dropdown to select a model for inference.\n",
185-
"model_dropdown = Dropdown(\n",
185+
"model_dropdown = widgets.Dropdown(\n",
186186
" options=txt2img_models,\n",
187187
" value=\"model-txt2img-stabilityai-stable-diffusion-v2-fp16\",\n",
188188
" description=\"Select a model\",\n",

introduction_to_amazon_algorithms/object_detection_tensorflow/Amazon_Tensorflow_Object_Detection.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"outputs": [],
157157
"source": [
158158
"import IPython\n",
159-
"from ipywidgets import Dropdown\n",
159+
"import ipywidgets as widgets\n",
160160
"from sagemaker.jumpstart.notebook_utils import list_jumpstart_models\n",
161161
"from sagemaker.jumpstart.filters import And, Or\n",
162162
"\n",
@@ -166,7 +166,7 @@
166166
")\n",
167167
"tensorflow_od_models = list_jumpstart_models(filter=filter_value)\n",
168168
"# display the model-ids in a dropdown, for user to select a model.\n",
169-
"dropdown = Dropdown(\n",
169+
"dropdown = widgets.Dropdown(\n",
170170
" options=tensorflow_od_models,\n",
171171
" value=model_id,\n",
172172
" description=\"SageMaker Built-In TensorFlow Object Detection Models:\",\n",

0 commit comments

Comments
 (0)