Using Keyboard Shortcuts to Execute Cells in Jupyter Notebooks
Executing cells in Jupyter Notebooks can be done quickly and efficiently using various keyboard shortcuts, saving you time and effort. Here are the shortcuts you can use:
Mac
- Shift + Enter: Execute the current cell and insert a new cell below.
- Ctrl + Enter: Execute the current cell and insert a new cell below, without creating a new output display.
Windows/Linux
- Shift + Enter: Execute the current cell and insert a new cell below.
- Ctrl + Enter: Execute the current cell and move to the next cell.
Additional Shortcuts
- Alt + Enter: Execute the current cell and create a new output display below (Mac), or move to the next cell (Windows/Linux).
- Ctrl + Shift + Enter: Execute the current cell and create a new output display below (Mac), or create a new cell below (Windows/Linux).
Tips and Tricks
- You can also use the Run Cell button in the Jupyter Notebook toolbar, or the Run menu option (macOS) or Run -> Run Cell (Windows/Linux).
- To execute a selection of cells, use Shift + Alt + Enter (Mac) or Shift + Ctrl + Enter (Windows/Linux).
- To execute a cell and move to the next cell, use Ctrl + Shift + Enter (all platforms).
By using these keyboard shortcuts, you'll be able to work more efficiently and quickly in your Jupyter Notebooks. Happy coding!
Text to Image
Explore all Text to Image models
data = client.workers.ai.with_raw_response.run(
"@cf/lykon/dreamshaper-8-lcm",
account_id=account_id,
prompt="A software developer incredibly excited about AI, huge smile",
)
display(Image(data.read()))

Image to Text
Explore all Image to Text models
url = "https://blog.cloudflare.com/content/images/2017/11/lava-lamps.jpg"
image_request = requests.get(url, allow_redirects=True)
display(Image(image_request.content, format="jpg"))
data = client.workers.ai.run(
"@cf/llava-hf/llava-1.5-7b-hf",
account_id=account_id,
image=image_request.content,
prompt="Describe this photo",
max_tokens=2048
)
print(data["description"])

The image features a display of various colored lava lamps. There are at least 14 lava lamps in the scene, each with a different color and design. The lamps are arranged in a visually appealing manner, with some placed closer to the foreground and others further back. The display creates an eye-catching and vibrant atmosphere, showcasing the diverse range of lava lamps available.
Automatic Speech Recognition
Explore all Speech Recognition models
url = "https://raw.githubusercontent.com/craigsdennis/notebooks-cloudflare-workers-ai/main/assets/craig-rambling.mp3"
display(Audio(url))
audio = requests.get(url)
response = client.workers.ai.run(
"@cf/openai/whisper",
account_id=account_id,
audio=audio.content
)
response
Your browser does not support the audio element.
{'text': "Hello there, I'm making a recording for a Jupiter notebook. That's a Python notebook, Jupiter, J-U-P-Y-T-E-R. Not to be confused with the planet. Anyways, let me hear, I'm gonna talk a little bit, I'm gonna make a little bit of noise, say some hard words, I'm gonna say Kubernetes, I'm not actually even talking about Kubernetes, I just wanna see if I can do Kubernetes. Anyway, this is a test of transcription and let's see how we're dead.",
'word_count': 84,
'vtt': "WEBVTT\n\n00.280 --> 01.840\nHello there, I'm making a\n\n01.840 --> 04.060\nrecording for a Jupiter notebook.\n\n04.060 --> 06.440\nThat's a Python notebook, Jupiter,\n\n06.440 --> 07.720\nJ -U -P -Y -T\n\n07.720 --> 09.420\n-E -R. Not to be\n\n09.420 --> 12.140\nconfused with the planet. Anyways,\n\n12.140 --> 12.940\nlet me hear, I'm gonna\n\n12.940 --> 13.660\ntalk a little bit, I'm\n\n13.660 --> 14.600\ngonna make a little bit\n\n14.600 --> 16.180\nof noise, say some hard\n\n16.180 --> 17.540\nwords, I'm gonna say Kubernetes,\n\n17.540 --> 18.420\nI'm not actually even talking\n\n18.420 --> 19.500\nabout Kubernetes, I just wanna\n\n19.500 --> 20.300\nsee if I can do\n\n20.300 --> 22.120\nKubernetes. Anyway, this is a\n\n22.120 --> 24.080\ntest of transcription and let's\n\n24.080 --> 26.280\nsee how we're dead.",
'words': [{'word': 'Hello',
'start': 0.2800000011920929,
'end': 0.7400000095367432},
{'word': 'there,', 'start': 0.7400000095367432, 'end': 1.2400000095367432},
{'word': "I'm", 'start': 1.2400000095367432, 'end': 1.4800000190734863},
{'word': 'making', 'start': 1.4800000190734863, 'end': 1.6799999475479126},
{'word': 'a', 'start': 1.6799999475479126, 'end': 1.840000033378601},
{'word': 'recording', 'start': 1.840000033378601, 'end': 2.2799999713897705},
{'word': 'for', 'start': 2.2799999713897705, 'end': 2.6600000858306885},
{'word': 'a', 'start': 2.6600000858306885, 'end': 2.799999952316284},
{'word': 'Jupiter', 'start': 2.799999952316284, 'end': 3.2200000286102295},
{'word': 'notebook.', 'start': 3.2200000286102295, 'end': 4.059999942779541},
{'word': "That's", 'start': 4.059999942779541, 'end': 4.28000020980835},
{'word': 'a', 'start': 4.28000020980835, 'end': 4.380000114440918},
{'word': 'Python', 'start': 4.380000114440918, 'end': 4.679999828338623},
{'word': 'notebook,', 'start': 4.679999828338623, 'end': 5.460000038146973},
{'word': 'Jupiter,', 'start': 5.460000038146973, 'end': 6.440000057220459},
{'word': 'J', 'start': 6.440000057220459, 'end': 6.579999923706055},
{'word': '-U', 'start': 6.579999923706055, 'end': 6.920000076293945},
{'word': '-P', 'start': 6.920000076293945, 'end': 7.139999866485596},
{'word': '-Y', 'start': 7.139999866485596, 'end': 7.440000057220459},
{'word': '-T', 'start': 7.440000057220459, 'end': 7.71999979019165},
{'word': '-E', 'start': 7.71999979019165, 'end': 7.920000076293945},
{'word': '-R.', 'start': 7.920000076293945, 'end': 8.539999961853027},
{'word': 'Not', 'start': 8.539999961853027, 'end': 8.880000114440918},
{'word': 'to', 'start': 8.880000114440918, 'end': 9.300000190734863},
{'word': 'be', 'start': 9.300000190734863, 'end': 9.420000076293945},
{'word': 'confused', 'start': 9.420000076293945, 'end': 9.739999771118164},
{'word': 'with', 'start': 9.739999771118164, 'end': 9.9399995803833},
{'word': 'the', 'start': 9.9399995803833, 'end': 10.039999961853027},
{'word': 'planet.', 'start': 10.039999961853027, 'end': 11.380000114440918},
{'word': 'Anyways,', 'start': 11.380000114440918, 'end': 12.140000343322754},
{'word': 'let', 'start': 12.140000343322754, 'end': 12.420000076293945},
{'word': 'me', 'start': 12.420000076293945, 'end': 12.520000457763672},
{'word': 'hear,', 'start': 12.520000457763672, 'end': 12.800000190734863},
{'word': "I'm", 'start': 12.800000190734863, 'end': 12.880000114440918},
{'word': 'gonna', 'start': 12.880000114440918, 'end': 12.9399995803833},
{'word': 'talk', 'start': 12.9399995803833, 'end': 13.100000381469727},
{'word': 'a', 'start': 13.100000381469727, 'end': 13.260000228881836},
{'word': 'little', 'start': 13.260000228881836, 'end': 13.380000114440918},
{'word': 'bit,', 'start': 13.380000114440918, 'end': 13.5600004196167},
{'word': "I'm", 'start': 13.5600004196167, 'end': 13.65999984741211},
{'word': 'gonna', 'start': 13.65999984741211, 'end': 13.739999771118164},
{'word': 'make', 'start': 13.739999771118164, 'end': 13.920000076293945},
{'word': 'a', 'start': 13.920000076293945, 'end': 14.199999809265137},
{'word': 'little', 'start': 14.199999809265137, 'end': 14.4399995803833},
{'word': 'bit', 'start': 14.4399995803833, 'end': 14.600000381469727},
{'word': 'of', 'start': 14.600000381469727, 'end': 14.699999809265137},
{'word': 'noise,', 'start': 14.699999809265137, 'end': 15.460000038146973},
{'word': 'say', 'start': 15.460000038146973, 'end': 15.859999656677246},
{'word': 'some', 'start': 15.859999656677246, 'end': 16},
{'word': 'hard', 'start': 16, 'end': 16.18000030517578},
{'word': 'words,', 'start': 16.18000030517578, 'end': 16.540000915527344},
{'word': "I'm", 'start': 16.540000915527344, 'end': 16.639999389648438},
{'word': 'gonna', 'start': 16.639999389648438, 'end': 16.719999313354492},
{'word': 'say', 'start': 16.719999313354492, 'end': 16.920000076293945},
{'word': 'Kubernetes,',
'start': 16.920000076293945,
'end': 17.540000915527344},
{'word': "I'm", 'start': 17.540000915527344, 'end': 17.65999984741211},
{'word': 'not', 'start': 17.65999984741211, 'end': 17.719999313354492},
{'word': 'actually', 'start': 17.719999313354492, 'end': 18},
{'word': 'even', 'start': 18, 'end': 18.18000030517578},
{'word': 'talking', 'start': 18.18000030517578, 'end': 18.420000076293945},
{'word': 'about', 'start': 18.420000076293945, 'end': 18.6200008392334},
{'word': 'Kubernetes,', 'start': 18.6200008392334, 'end': 19.1200008392334},
{'word': 'I', 'start': 19.1200008392334, 'end': 19.239999771118164},
{'word': 'just', 'start': 19.239999771118164, 'end': 19.360000610351562},
{'word': 'wanna', 'start': 19.360000610351562, 'end': 19.5},
{'word': 'see', 'start': 19.5, 'end': 19.719999313354492},
{'word': 'if', 'start': 19.719999313354492, 'end': 19.8799991607666},
{'word': 'I', 'start': 19.8799991607666, 'end': 19.940000534057617},
{'word': 'can', 'start': 19.940000534057617, 'end': 20.079999923706055},
{'word': 'do', 'start': 20.079999923706055, 'end': 20.299999237060547},
{'word': 'Kubernetes.',
'start': 20.299999237060547,
'end': 21.440000534057617},
{'word': 'Anyway,', 'start': 21.440000534057617, 'end': 21.799999237060547},
{'word': 'this', 'start': 21.799999237060547, 'end': 21.920000076293945},
{'word': 'is', 'start': 21.920000076293945, 'end': 22.020000457763672},
{'word': 'a', 'start': 22.020000457763672, 'end': 22.1200008392334},
{'word': 'test', 'start': 22.1200008392334, 'end': 22.299999237060547},
{'word': 'of', 'start': 22.299999237060547, 'end': 22.639999389648438},
{'word': 'transcription',
'start': 22.639999389648438,
'end': 23.139999389648438},
{'word': 'and', 'start': 23.139999389648438, 'end': 23.6200008392334},
{'word': "let's", 'start': 23.6200008392334, 'end': 24.079999923706055},
{'word': 'see', 'start': 24.079999923706055, 'end': 24.299999237060547},
{'word': 'how', 'start': 24.299999237060547, 'end': 24.559999465942383},
{'word': "we're", 'start': 24.559999465942383, 'end': 24.799999237060547},
{'word': 'dead.', 'start': 24.799999237060547, 'end': 26.280000686645508}]}
Translations
Explore all Translation models
result = client.workers.ai.run(
"@cf/meta/m2m100-1.2b",
account_id=account_id,
text="Artificial intelligence is pretty impressive these days. It is a bonkers time to be a builder",
source_lang="english",
target_lang="spanish"
)
print(result["translated_text"])
La inteligencia artificial es bastante impresionante en estos días.Es un buen momento para ser un constructor
Text Classification
Explore all Text Classification models
result = client.workers.ai.run(
"@cf/huggingface/distilbert-sst-2-int8",
account_id=account_id,
text="This taco is delicious"
)
result
[TextClassification(label='NEGATIVE', score=0.00012679687642958015), TextClassification(label='POSITIVE', score=0.999873161315918)]
