Join the conversation

Join the community of Machine Learners and AI enthusiasts.

Sign Up
awacke1Β 
posted an update Oct 23
Post
1896
Since 2022 I have been trying to understand how to support advancement of the two best python patterns for AI development which are:
1. Streamlit
2. Gradio

The reason I chose them in this order was the fact that the streamlit library had the timing drop on gradio by being available with near perfection about a year or two before training data tap of GPT.

Nowadays its important that if you want current code to be right on generation it requires understanding of consistency in code method names so no manual intervention is required with each try.

With GPT and Claude being my top two for best AI pair programming models, I gravitate towards streamlit since aside from common repeat errors on cache and experimental functions circa 2022 were not solidified.
Its consistency therefore lacks human correction needs. Old dataset error situations are minimal.

Now, I seek to make it consistent on gradio side. Why? Gradio lapped streamlit for blocks paradigm and API for free which are I feel are amazing features which change software engineering forever.

For a few months I thought BigCode would become the new best model due to its training corpus datasets, yet I never felt it got to market as the next best AI coder model.

I am curious on Gradio's future and how. If the two main models (GPT and Claude) pick up the last few years, I could then code with AI without manual intervention. As it stands today Gradio is better if you could get the best coding models to not repeatedly confuse old syntax as current syntax yet we do live in an imperfect world!

Is anyone using an AI pair programming model that rocks with Gradio's latest syntax? I would like to code with a model that knows how to not miss the advancements and syntax changes that gradio has had in the past few years. Trying grok2 as well.

My IDE coding love is HF. Its hands down faster (100x) than other cloud paradigms. Any tips on models best for gradio coding I can use?

--Aaron

I'm still inexperienced in coding with AI, so I'll leave it to others to recommend a model.

As it stands today Gradio is better if you could get the best coding models to not repeatedly confuse old syntax as current syntax yet we do live in an imperfect world!

Gradio changes its syntax and bug characteristics when the version changes even 0.01 seriously. Even if a human handles Gradio, it is a kind of craftsmanship to make it error-free on the first try, so there will be no appropriate data set to train a language model...
The transition from Gradio 4.x to 5.x doesn't seem to be as hard as it was for 3.x, and there are guides available.
In fact, I've already migrated a few spaces.
However, I wish the library would accept deprecated kwargs and throw them away on its own, even if the option changes that accompany the fundamental refactoring are unavoidable...🀒

Gradio 5 guide:

https://huggingface.co/blog/gradio-5
https://github.com/gradio-app/gradio/issues/9463

Β·

Thankyou for the tips and insight on Gradio 5. Much appreciated,

I use gradio , I'm a .net coder and not a python coder but I manage.
I chose gradio because for me it worked as well as I just run my python file with a click .
But for streamlet I chose not to use it despite many I terfaves which are clones of chat got use this.
Also because of the streamlet run command and not being able to just click my py file ! Quite lazy reason. But it's usability .
Because , how will I remember which apps are streamlet and which are gradio and which are ... So even a Console app can be run with a click ! ...
Personally I also have trouble with docker so I avoid it despite knowing that it is a good resource !

So we make all these choices for mad crazy reasons . But for me usability is generally the reason ... Hence I don't like npm apps either !
.. but there are a lot of options and you have to find which rot is best for you

Β·

In they are basically the same type of thing ! Just forget tkinter as they failed !

After trying pretty much everything I gave the latest Grok2 a spin at converting my old malfunctioning Python/Gradio code which no longer adheres to syntax innovations and feature adds within python and gradio.

Grok2 in my opinion is the only one which could do this. Examine below instant one shot win by Grok2 with gradio! Greatest thing about it is it shows references via tweet so you can find where the intelligence was added so Grok2 is using modern syntax and unlike OpenAI and Anthropic, it produces innovative modern results aware of recent innovation.

Grok2 for the win I guess!

Tried a straw man example shown below which fails on others but works on Grok2:

Original which fails now if you upgrade Gradio:

import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('characters.pkl')

labels = learn.dls.vocab
def predict(img):
    pred,pred_idx,probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "Video Game Character Classifier"
# description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
#article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
examples = ['ellie.jpg','arthur.jpg','kratos.jpg','ellielou.jpg']
interpretation='default'
enable_queue=True

gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(128, 128)),outputs=gr.outputs.Label(),title=title,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()

Second Grok2 prompt (first switched to blocks shown below).

image.png

Grok2's second shot with examples of errors gave working code and also tweet references!!

image.png

import gradio as gr
from fastai.vision.all import *
import skimage

learn = load_learner('characters.pkl')

labels = learn.dls.vocab
def predict(img):
    pred, pred_idx, probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "Video Game Character Classifier"
examples = ['ellie.jpg', 'arthur.jpg', 'kratos.jpg', 'ellielou.jpg']

# Updated Gradio Interface with new syntax
with gr.Blocks() as demo:
    gr.Markdown("# " + title)
    # Use width and height instead of shape
    image_input = gr.Image(width=128, height=128)
    label_output = gr.Label()
    
    # Create submit button
    submit_btn = gr.Button("Classify")
    submit_btn.click(fn=predict, inputs=image_input, outputs=label_output)

    # Adding examples
    gr.Examples(examples, inputs=image_input, outputs=label_output, fn=predict)

demo.launch()