-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:bbelderbos/bobcodesit
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Image classification with Marvin AI | ||
|
||
Another cool thing you can do with Marvin AI is classifying images. 💡 💪 | ||
|
||
I just gave it my profile picture and asked what type of programmer I am and what I am holding in my hands. 🐍🪄 | ||
|
||
See below - it did a great job! 😍 📈 | ||
|
||
``` | ||
import marvin | ||
img = marvin.Image( | ||
"https://pbs.twimg.com/profile_images/1365563799571431428/wj7Hu5-6_400x400.jpg" | ||
) | ||
programer = marvin.classify( | ||
img, | ||
labels=["Rustacean", "Pythonista", "Javaist", "Rubyist", "Gopher", "Haskellites"], | ||
) | ||
object_in_hands = marvin.classify( | ||
img, | ||
labels=[ | ||
"stick", | ||
"tool", | ||
"flag", | ||
"banner", | ||
"staff", | ||
"book", | ||
"smartphone", | ||
"bottle", | ||
"pen", | ||
"notebook", | ||
"other", | ||
], | ||
instructions="What object is the programmer holding?", | ||
) | ||
print(f"Programmer is a {programer} and is holding a {object_in_hands}") | ||
# Outputs: | ||
# Programmer is a Pythonista and is holding a staff | ||
``` | ||
|
||
#marvinai |
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Use itertools + random to simulate rolling dice | ||
|
||
🎲 Simulate rolling two 6-sided dice and get all possible outcomes ... `range` + `itertools` + `random` are great for this: | ||
|
||
``` | ||
>>> import random | ||
>>> import itertools | ||
>>> dice_sides = range(1, 7) | ||
>>> all_possible_rolls = list(itertools.product(dice_sides, repeat=2)) | ||
>>> all_possible_rolls[:2] | ||
[(1, 1), (1, 2)] | ||
>>> all_possible_rolls[-2:] | ||
[(6, 5), (6, 6)] | ||
>>> for _ in range(3): random.choice(all_possible_rolls) | ||
... | ||
(3, 3) | ||
(6, 4) | ||
(2, 1) | ||
``` | ||
|
||
#itertools |