Skip to content

Commit

Permalink
Fix links in livebooks, remove static files from the repository and u…
Browse files Browse the repository at this point in the history
…se cache instead
  • Loading branch information
daniel-jodlos committed May 28, 2024
1 parent da2bf09 commit 74f5a30
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
17 changes: 9 additions & 8 deletions examples/1-basic-tutorial.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```elixir
Mix.install(
[
{:ex_vision, path: Path.join(__DIR__, "..")},
:ex_vision,
:kino,
:kino_bumblebee,
:stb_image,
Expand Down Expand Up @@ -33,7 +33,7 @@ The main objective of ExVision is ease of use. This sacrifices some control over

```elixir
alias ExVision.Classification.MobileNetV3Small, as: Classifier
alias ExVision.Detection.Ssdlite320_MobileNetv3, as: Detector
alias ExVision.Detection.FasterRCNN_ResNet50_FPN, as: Detector
alias ExVision.Segmentation.DeepLabV3_MobileNetV3, as: Segmentation

{:ok, classifier} = Classifier.load()
Expand Down Expand Up @@ -83,8 +83,12 @@ input = Kino.Input.image("Image to evaluate", format: :jpeg)
```elixir
img_path =
case Kino.Input.read(input) do
nil -> Path.join(__DIR__, "files/cat.jpg")
%{file_ref: image} -> Kino.Input.file_path(image)
nil ->
{:ok, file} = ExVision.Cache.lazy_get(ExVision.Cache, "cat.jpg")
file

%{file_ref: image} ->
Kino.Input.file_path(image)
end

image = Image.open!(img_path)
Expand Down Expand Up @@ -127,10 +131,7 @@ scored_list = Kino.Bumblebee.ScoredList.new(predictions)

Kino.Layout.grid(
[
Kino.Layout.grid([
image,
Kino.Text.new("This image shows an object of class `#{Atom.to_string(top_prediction)}`")
]),
image,
Kino.Layout.grid([Kino.Text.new("Class probabilities"), scored_list])
],
columns: 2,
Expand Down
2 changes: 1 addition & 1 deletion examples/2-usage-as-nx-serving.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```elixir
Mix.install(
[
{:ex_vision, path: Path.join(__DIR__, "..")},
:ex_vision,
:exla,
:kino,
:nx,
Expand Down
13 changes: 8 additions & 5 deletions examples/3-membrane.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```elixir
Mix.install(
[
{:ex_vision, path: Path.join(__DIR__, "..")},
:ex_vision,
:image,
:membrane_core,
:membrane_file_plugin,
Expand Down Expand Up @@ -54,7 +54,7 @@ But before we dive into the code, here are a few tips that will make it both eas
defmodule Membrane.ExVision.Detector do
use Membrane.Filter

alias ExVision.Detection.FasterRCNN_ResNet50_FPN, as: Model
alias ExVision.Detection.Ssdlite320_MobileNetv3, as: Model
alias ExVision.Types.BBox

# Define both input and output pads
Expand Down Expand Up @@ -161,11 +161,11 @@ defmodule Pipeline do
use Membrane.Pipeline

@impl true
def handle_init(_ctx, output_file) do
def handle_init(_ctx, {input_file, output_file}) do
structure =
child(%Membrane.File.Source{
chunk_size: 1024,
location: Path.join(__DIR__, "files/big-buck-bunny-short.mp4"),
location: input_file,
seekable?: true
})
|> child(:demuxer, %Membrane.MP4.Demuxer.ISOM{optimize_for_non_fast_start?: true})
Expand Down Expand Up @@ -210,7 +210,10 @@ We have written the Filter responsible for applying our model and the full proce

```elixir
output_file = Path.join("/tmp", "#{DateTime.utc_now()}.mp4")
{:ok, _supervisor_pid, pipeline_pid} = Membrane.Pipeline.start(Pipeline, output_file)
{:ok, input_file} = ExVision.Cache.lazy_get(ExVision.Cache, "big-buck-bunny-short.mp4")

{:ok, _supervisor_pid, pipeline_pid} =
Membrane.Pipeline.start(Pipeline, {input_file, output_file})

Kino.nothing()
```
Expand Down
Binary file removed examples/files/big-buck-bunny-short.mp4
Binary file not shown.
Binary file removed examples/files/cat.jpg
Binary file not shown.
Binary file removed examples/files/multipla.jpg
Binary file not shown.

0 comments on commit 74f5a30

Please sign in to comment.