Spaces:
Sleeping
Sleeping
Revert "Remove all scribble bird stuff"
Browse filesThis reverts commit 538f222ee9895a225538ce8d5eabe67546ec6389.
public-apps/sd_controlnet.livemd
CHANGED
|
@@ -70,6 +70,53 @@ serving =
|
|
| 70 |
)
|
| 71 |
```
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
## Your own input
|
| 74 |
|
| 75 |
```elixir
|
|
|
|
| 70 |
)
|
| 71 |
```
|
| 72 |
|
| 73 |
+
```elixir
|
| 74 |
+
Kino.Text.new("Scribble Bird")
|
| 75 |
+
livebook_dir = Path.absname(__DIR__)
|
| 76 |
+
|
| 77 |
+
bird_file_input =
|
| 78 |
+
Kino.Input.text("Bird file path", default: livebook_dir <> "/scribble_bird.png")
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
```elixir
|
| 82 |
+
bird_file = Kino.Input.read(bird_file_input)
|
| 83 |
+
|
| 84 |
+
bird_image = StbImage.read_file!(bird_file) |> StbImage.to_nx()
|
| 85 |
+
|
| 86 |
+
bird_image_tensor =
|
| 87 |
+
bird_image
|
| 88 |
+
|> Nx.reshape({512, 512, 3})
|
| 89 |
+
|> NxImage.to_continuous(0, 1)
|
| 90 |
+
|
| 91 |
+
Kino.Image.new(bird_image)
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
```elixir
|
| 95 |
+
bird_prompt = "a bird, high quality, detailed"
|
| 96 |
+
bird_negative_prompt = "ugly, low quality, blurry"
|
| 97 |
+
|
| 98 |
+
Kino.Layout.grid([
|
| 99 |
+
Kino.Text.new("prompt: " <> bird_prompt),
|
| 100 |
+
Kino.Text.new("negative prompt:" <> bird_negative_prompt)
|
| 101 |
+
])
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
```elixir
|
| 105 |
+
Kino.Text.new("Generate image ...")
|
| 106 |
+
|
| 107 |
+
output =
|
| 108 |
+
Nx.Serving.run(serving, %{
|
| 109 |
+
prompt: bird_prompt,
|
| 110 |
+
negative_prompt: bird_negative_prompt,
|
| 111 |
+
controlnet_conditioning: bird_image_tensor
|
| 112 |
+
})
|
| 113 |
+
|
| 114 |
+
for result <- output.results do
|
| 115 |
+
Kino.Image.new(result.image)
|
| 116 |
+
end
|
| 117 |
+
|> Kino.Layout.grid(columns: 2)
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
## Your own input
|
| 121 |
|
| 122 |
```elixir
|