Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bbelderbos/bobcodesit
Browse files Browse the repository at this point in the history
  • Loading branch information
bbelderbos committed Jul 10, 2024
2 parents 7d8d20e + fa9e31e commit 329268d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ This file gets generated by [this script](index.py).
- [Itertools.count](notes/20220906094357.md)
- [Itertools.cycle](notes/20240126101005.md)
- [Split a sequence into pairs](notes/20231216210001.md)
- [Use itertools + random to simulate rolling dice](notes/20240702100917.md)

## Libraries

Expand All @@ -274,6 +275,7 @@ This file gets generated by [this script](index.py).

## Marvinai

- [Image classification with marvin ai](notes/20240702100735.md)
- [Using marvin ai to extract geo locations](notes/20240628165703.md)

## Matchcase
Expand Down
44 changes: 44 additions & 0 deletions notes/20240702100735.md
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
24 changes: 24 additions & 0 deletions notes/20240702100917.md
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

0 comments on commit 329268d

Please sign in to comment.