You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/5.blog/2.drawing-app-with-nuxt-and-cloudflare-r2.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -467,8 +467,6 @@ Or go to https://admin.hub.nuxt.com and select your project.
467
467
468
468
Congratulations! You've now built a fully functional drawing application using Nuxt and Cloudflare R2 for storage. Users can create drawings, save them to the cloud, and access them from anywhere.
469
469
470
-
Next, we are going to leverage Cloudflare AI to generate the alternative text for the user drawings (accessibility & SEO) as well as generating an alternative drawing using AI.
471
-
472
470
Feel free to expand on this foundation and add your own unique features to make Atidraw yours!
Checkout the next article on how to leverage Cloudflare AI to generate the alternative text for the user drawings (accessibility & SEO) as well as generating an alternative drawing using AI: [Cloudflare AI for User Experience](/blog/cloudflare-ai-for-user-experience).
Checkout how we created Atidraw in the ["Code, Draw, Deploy: A drawing app with Nuxt & Cloudflare R2"](/blog/drawing-app-with-nuxt-and-cloudflare-r2) blog post.
:img{src="https://hub.nuxt.com/button.svg"alt="Deploy to NuxtHub"width="174"height="32"}
33
+
This is important to know how Cloudflare AI models are billed.
34
+
35
+
Cloudflare free allocation allows anyone to use a total of 10,000 Neurons per day at no charge.
36
+
37
+
Neurons are Cloudflare way of measuring AI outputs across different models. To give you a sense of what you can accomplish with 10,000 Neurons, you can generate:
38
+
- 100-200 LLM responses
39
+
- 500 translations
40
+
- 500 seconds of speech-to-text audio
41
+
- 10,000 text classifications
42
+
- 1,500 - 15,000 embeddings
43
+
44
+
Once you reach the free allocation, you can use the AI models with a pay-as-you-go model of $0.011 / 1,000 Neurons.
45
+
46
+
::tip
47
+
**AI Models in beta are free to use**, at this time, all the models we use in this tutorial are in beta, **so you we use them for free**.
To generate the alternative text for the user drawings, we use the [LLaVA](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/) model.
100
+
101
+
Let's see our current `/api/upload` route:
102
+
103
+
```ts [server/api/upload.post.ts]
104
+
exportdefaulteventHandler(async (event) => {
105
+
// Make sure the user is authenticated to upload
106
+
const { user } =awaitrequireUserSession(event)
107
+
108
+
// Read the form data
109
+
const form =awaitreadFormData(event)
110
+
const drawing =form.get('drawing') asFile
111
+
112
+
// Make sure the drawing is a jpeg image and is not larger than 1MB
While working on [`hubAI()`](/docs/features/ai), I wanted to add a feature to generate the alt text for the user drawings.
152
+
// ...
153
+
return hubBlob().put(`${name}.jpg`, drawing, {
154
+
// ...
155
+
customMetadata: {
156
+
// ...
157
+
userUrl: user.url,
158
+
+ description
159
+
},
160
+
})
161
+
})
162
+
```
43
163
44
-
- Image Alt text generation with [`hubAI()`](/docs/features/ai) and [LLaVA](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/)
45
-
- Gerate an image based from the drawing with [`hubAI()`](/docs/features/ai) and [Stable Diffusion](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-img2img/)
164
+
Lastly, we need to update our listing page to display the description in the `<img>` tag but also in the `title` attribute so the user can see the description when hovering the image.
To generate a new drawing based from the drawing and the alternative text, we need to use the [Stable Diffusion IMG2IMG](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-img2img/) model.
Sometime the AI generated image is black, this is because the model is not able to generate an image from the description, most of the time because it is a sensitive content or misunderstood the description.
294
+
::
295
+
296
+
## Conclusion
297
+
298
+
This is the end of this tutorial on how to use Cloudflare AI models in a Nuxt application. I hope you enjoyed it and that it gave you some ideas on how to use AI in your Nuxt application.
299
+
300
+
Feel free to expand on this foundation and add your own unique features to make Atidraw yours!
0 commit comments