<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gautam Negi  on Medium]]></title>
        <description><![CDATA[Stories by Gautam Negi  on Medium]]></description>
        <link>https://medium.com/@gautam-negi?source=rss-f3c5d0586842------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eg0_3H3b3YPlllMQ</url>
            <title>Stories by Gautam Negi  on Medium</title>
            <link>https://medium.com/@gautam-negi?source=rss-f3c5d0586842------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:54:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gautam-negi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Fixing INVALID_ARGUMENT When Using Images with Gemini Veo 3 (Without Vertex AI)]]></title>
            <link>https://gautam-negi.medium.com/fixing-invalid-argument-when-using-images-with-gemini-veo-3-without-vertex-ai-381817cd6189?source=rss-f3c5d0586842------2</link>
            <guid isPermaLink="false">https://medium.com/p/381817cd6189</guid>
            <dc:creator><![CDATA[Gautam Negi ]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 10:23:19 GMT</pubDate>
            <atom:updated>2025-12-04T10:27:17.431Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with <strong>Google Gemini Veo 3</strong> to generate videos, you can pass in both <strong>images</strong> and <strong>text prompts</strong> to guide the generation.</p><p>But if you’re using the Python SDK (without Vertex AI) and directly passing image bytes, you might hit this frustrating error:</p><pre>google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {<br> &#39;error&#39;: {<br> &#39;code&#39;: 400,<br> &#39;message&#39;: &#39;Input instance with `image` should contain both `bytesBase64Encoded` and `mimeType` in underlying struct value.&#39;,<br> &#39;status&#39;: &#39;INVALID_ARGUMENT&#39;<br> }<br>}</pre><p>Here’s exactly what caused it and how I solved it.</p><h3>The Setup</h3><p>I was trying to generate a video by passing:</p><p>Here’s what Itried:</p><p>Then I passed image_part into the generate_video() call for Veo 3.<br> And boom - 400 INVALID_ARGUMENT.</p><h3>Why This Happens</h3><p>The issue is <strong>not</strong> with the image bytes themselves — they’re fine.<br> The problem is that types.Part.from_bytes produces a <strong>Blob-like structure</strong>, but Gemini Veo 3 expects a very specific Image object with:</p><p>In other words:</p><ul><li><strong>Blob</strong> = generic container of bytes</li><li><strong>Image</strong> = a typed object that Veo 3 understands as a visual input</li></ul><p>Passing the wrong type leads to this bytesBase64Encoded error.</p><h3>The Fix: Convert Blob → Image</h3><p>Here’s the function I now use to convert a Blob into a proper Image object before sending it to Gemini Veo 3:</p><h3>Full Working Example with Veo 3</h3><p>With this approach, Gemini Veo 3 correctly recognizes the image and generates the video as expected — no more INVALID_ARGUMENT errors.</p><h3>Key Takeaways</h3><ul><li><strong>Gemini Veo 3 requires </strong><strong>Image objects</strong>, not generic byte blobs.</li><li>If you get an error saying bytesBase64Encoded is missing, it&#39;s likely that you passed a Blob or Part instead of an Image.</li><li>The solution is a simple conversion step before calling generate_video().</li></ul><p><em>Originally published at </em><a href="https://medium.com/@gautamnegi0202/d6077c1bffdc"><em>https://medium.com</em></a><em> on December 4, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=381817cd6189" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Convert Your YOLOv8 .pt Model into a TensorFlow.js Model with INT8 Quantization]]></title>
            <link>https://gautam-negi.medium.com/how-to-convert-your-yolov8-pt-model-into-a-tensorflow-js-model-with-int8-quantization-721657e82b88?source=rss-f3c5d0586842------2</link>
            <guid isPermaLink="false">https://medium.com/p/721657e82b88</guid>
            <category><![CDATA[computervisiondevelopment]]></category>
            <category><![CDATA[tfjs]]></category>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[ultralytics]]></category>
            <category><![CDATA[tensorflowjs]]></category>
            <dc:creator><![CDATA[Gautam Negi ]]></dc:creator>
            <pubDate>Fri, 30 Aug 2024 07:24:30 GMT</pubDate>
            <atom:updated>2025-12-04T10:30:29.479Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Convert Your YOLOv8 .pt Model into a TensorFlow.js Model with INT8 Quantization</h3><p>In this article, we will explore the process of converting a YOLOv8 .pt model into a TensorFlow.js model with INT8 quantization. This conversion is crucial for deploying YOLO models on web interfaces for real-time object detection while optimizing performance and reducing model size.</p><h3>Why Convert YOLO Models to TensorFlow.js?</h3><p>Converting YOLO models to TensorFlow.js has several benefits:</p><ol><li><strong>Real-time Object Detection on the Web</strong>: TensorFlow.js allows running models directly in the browser without server-side processing, enabling real-time object detection on web applications.</li><li><strong>Cross-Platform Compatibility</strong>: Models can be run on various devices and browsers, including mobile and desktop.</li><li><strong>Performance Optimization</strong>: INT8 quantization reduces model size and improves inference speed, making it suitable for devices with lower computational power.</li></ol><p>In this article, we will explore the process of converting a YOLOv8 .pt model into a TensorFlow.js model with INT8 quantization. This conversion is crucial for deploying YOLO models on web interfaces for real-time object detection while optimizing performance and reducing model size.</p><h3>Why Convert YOLO Models to TensorFlow.js?</h3><p>Converting YOLO models to TensorFlow.js has several benefits:</p><ol><li><strong>Real-time Object Detection on the Web</strong>: TensorFlow.js allows running models directly in the browser without server-side processing, enabling real-time object detection on web applications.</li><li><strong>Cross-Platform Compatibility</strong>: Models can be run on various devices and browsers, including mobile and desktop.</li><li><strong>Performance Optimization</strong>: INT8 quantization reduces model size and improves inference speed, making it suitable for devices with lower computational power.</li></ol><h3>Issue in direct Conversion to TensorFlow.js with INT8 Quantization</h3><p>According to the Ultralytics documentation, the code to directly convert the .pt model to a TensorFlow.js model with INT8 quantization is as follows</p><pre>from ultralytics import YOLO<br><br>model = YOLO(&quot;&lt;model_path&gt;&quot;)<br>model.export(format = &quot;tfjs&quot;, int8 = True)</pre><p><strong>However, this approach often leads to an issue.</strong> When attempting to directly export the model using the above method, you may encounter the following error:</p><pre>TensorFlow SavedModel: export success ✅ 85.4s, saved as &#39;yolov8n_saved_model&#39; (40.4 MB)<br><br>TensorFlow GraphDef: starting export with tensorflow 2.16.2...<br>TensorFlow GraphDef: export failure ❌ 0.0s: &#39;_UserObject&#39; object has no attribute &#39;inputs&#39;<br>---------------------------------------------------------------------------<br>AttributeError                            Traceback (most recent call last)<br>&lt;ipython-input-5-2ace0f867ec6&gt; in &lt;cell line: 4&gt;()<br>      2 <br>      3 model = YOLO(&quot;yolov8n.pt&quot;)<br>----&gt; 4 model.export(format = &quot;tfjs&quot;, int8 = True)<br><br>5 frames<br>/usr/local/lib/python3.10/dist-packages/ultralytics/engine/exporter.py in export_pb(self, keras_model, prefix)<br>    913 <br>    914         m = tf.function(lambda x: keras_model(x))  # full model<br>--&gt; 915         m = m.get_concrete_function(tf.TensorSpec(keras_model.inputs[0].shape, keras_model.inputs[0].dtype))<br>    916         frozen_func = convert_variables_to_constants_v2(m)<br>    917         frozen_func.graph.as_graph_def()<br><br>AttributeError: &#39;_UserObject&#39; object has no attribute &#39;inputs&#39;</pre><p>This error occurs because of compatibility issues with the direct use of the export method for TensorFlow.js format conversion. The problem lies in handling TensorFlow graph definitions and the use of INT8 quantization directly in this step.</p><h3>Steps to Convert YOLO .pt Model to TensorFlow.js with INT8 Quantization: A Corrected Approach</h3><p>Let’s go through the step-by-step process to convert a YOLOv8 model from a .pt file to a TensorFlow.js model, incorporating INT8 quantization.</p><h4>Step 1: Install Required Dependencies</h4><p>First, install the necessary Python packages. We will use the Ultralytics library for handling YOLO models and TensorFlow for the conversion process.</p><pre>!pip install ultralytics<br>!pip install tensorflow==2.16.2<br>!pip install tensorflowjs</pre><h4>Step 2: Define Model Paths</h4><p>Define the path for your original YOLOv8 model.</p><pre># Define the model path<br>model_path = &quot;/content/yolov8n.pt&quot;  # Change to your actual model path</pre><h4>Step 3: Load and Convert the YOLO Model to SavedModel Format</h4><p>Using the YOLO class from the Ultralytics library, load your YOLO model and export it to the TensorFlow SavedModel format. The SavedModel format is versatile and can be used for deployment on different platforms, including TensorFlow.js.</p><pre>from ultralytics import YOLO</pre><pre># Load the YOLO model<br>model = YOLO(model_path)<br># Export the model to SavedModel format with INT8 quantization<br>model.export(format=&#39;saved_model&#39;, int8=True)</pre><h4>Step 4: Convert Saved Model to TensorFlow.js Format with INT8 Quantization</h4><p>Now, use the tensorflowjs_converter command to convert the Saved Model to TensorFlow.js format. The --quantize_uint8 flag is used for INT8 quantization, which significantly reduces model size and improves inference speed.</p><p>Replace &lt;saved_model_path&gt; and &lt;output_path&gt; with your actual paths:</p><pre>!tensorflowjs_converter --input_format=tf_saved_model --output_format=tfjs_graph_model --quantize_uint8 --output_node_names=&quot;output_node&quot; &lt;saved_model_path&gt; &lt;output_path&gt;</pre><ul><li>Replace &lt;saved_model_path&gt; with the path where the Saved Model is stored.</li><li>Replace &lt;output_path&gt; with the path where you want the TensorFlow.js model to be saved.</li></ul><h4>Step 5: Package the Converted Model(optional)</h4><p>After successfully converting your model to TensorFlow.js format, package it into a zip file for easy distribution and deployment.</p><pre>import shutil<br><br>tfjs_path = &#39;&lt;output_path&gt;&#39; # Change to your actual directory path<br><br># Define the directory containing the converted model<br>directory_to_zip = tfjs_path <br># Define the output zip file path<br>output_zip_file = f&#39;{tfjs_path}.zip&#39;<br># Create a zip archive<br>shutil.make_archive(output_zip_file.replace(&#39;.zip&#39;, &#39;&#39;), &#39;zip&#39;, directory_to_zip)</pre><h3>Summary</h3><p>This article outlines the corrected steps to convert a YOLOv8 .pt model into a TensorFlow.js model with INT8 quantization for optimized performance in web applications. Although the Ultralytics documentation suggests using the model.export(format=&quot;tfjs&quot;, int8=True) command for direct conversion, this often results in errors due to compatibility issues. To avoid this, first export the model to the TensorFlow SavedModel format with INT8 quantization, and then use the tensorflowjs_converter tool to convert the SavedModel to TensorFlow.js. This two-step approach ensures successful deployment of real-time object detection models on web platforms, improving both model size and inference speed.</p><h4>References</h4><ul><li><a href="https://docs.ultralytics.com/modes/export/#usage-examples">https://docs.ultralytics.com/modes/export/#usage-examples</a></li><li><a href="https://github.com/tensorflow/tfjs/tree/master/tfjs-converter">https://github.com/tensorflow/tfjs/tree/master/tfjs-converter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=721657e82b88" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>