|
import gradio as gr |
|
|
|
from fun_advaitbert import predict_CTH |
|
from fun_advaitbert import llm_model_function |
|
from fun_advaitbert import product_explaination |
|
|
|
title="<h1 style='color:green;text-align:center;font-size:2vw;'>AdvaitBERT:HS Code AI Explanability Through Mixtral 46.7B </a></h1>" |
|
description = """ |
|
AdvaitBERT is modified version of BERT (Bidirectional Encoder Representation for Transformers), \ |
|
finetuned on the Text corpus of Indian Customs Declarations. It is trained for performing \ |
|
downstream tasks like automating the tariff classification and validation process of Customs \ |
|
declarations in realtime. This model may help Customs administration to efficiently use AI assisted \ |
|
NLP in realtime Customs process like Assessment, Post Clearance Audit, thereby highlighting classification \ |
|
inconsistencies and help in revenue augmentation. |
|
""" |
|
|
|
article="<p style='color:black;text-align:right;font-size:1vw;'>Powered by NCTC </a></p>" |
|
|
|
|
|
css = """ |
|
.gradio-container { |
|
width: 100vw !important; |
|
min-height: 100vh !important; |
|
padding:0 !important; |
|
margin:0 !important; |
|
max-width: none !important; |
|
} |
|
""" |
|
|
|
footnote = """Note: All rights, including licensing and acceptable use policies, related to the AI models, can be found on their respective model pages on Hugging Face. Powered by NCTC |
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
textbox = gr.Textbox(label='Enter Your Product Descrption',lines=3,) |
|
textbox_2=textbox |
|
|
|
print('textbox',textbox) |
|
print('textbox_2',textbox_2) |
|
|
|
chat_prod = gr.Chatbot(label="Product Explanation", layout='panel') |
|
|
|
chat_alpha = gr.Chatbot(label="AI Explanability", layout='panel') |
|
chat_Advait=gr.Interface(predict_CTH,inputs=textbox,outputs="label",) |
|
|
|
|
|
submit = gr.Button('Submit', variant='primary',) |
|
submit_second = gr.Button('Submit', variant='secondary',) |
|
|
|
retry = gr.Button('🔄Retry', variant='secondary') |
|
undo = gr.Button('↩️Undo', variant='secondary') |
|
|
|
with gr.Blocks(css=css) as demo: |
|
gr.HTML(f'<h1><center> {title} </center></h1>') |
|
gr.Markdown(description) |
|
|
|
with gr.Row(): |
|
with gr.Column(scale=0,min_width=600): |
|
chat_Advait.render() |
|
|
|
with gr.Column(scale=1,min_width=600): |
|
chat_alpha.render() |
|
with gr.Row(equal_height=True): |
|
with gr.Column(scale=1): |
|
submit.render() |
|
with gr.Column(scale=1): |
|
undo.render() |
|
with gr.Column(scale=1): |
|
clear = gr.ClearButton(value='🗑️Clear',components=[chat_alpha,chat_prod,textbox]) |
|
chat_prod.render() |
|
|
|
|
|
gr.Markdown(footnote) |
|
textbox.submit(llm_model_function, [textbox, chat_alpha], [textbox, chat_alpha]) |
|
textbox_2.submit(product_explaination, [textbox_2, chat_prod], [textbox_2, chat_prod]) |
|
|
|
submit.click(llm_model_function,[textbox, chat_alpha], [textbox, chat_alpha]) |
|
submit.click(product_explaination,[textbox_2, chat_prod], [textbox_2, chat_prod]) |
|
|
|
undo.click(lambda x:x[:-1], [chat_alpha], [chat_alpha]) |
|
undo.click(lambda x:x[:-1], [chat_prod], [chat_prod]) |
|
|
|
gr.Examples([ |
|
['200 SI/SI/SI LPO ALUMINIUM LIDS (QTY: 8820000 PCS/PRICE: 21.'], |
|
], |
|
textbox) |
|
|
|
demo.launch(debug=True) |