Last active
May 6, 2025 06:10
-
-
Save fabiomatricardi/85eca8e6982488bf2a72d227b1cb3d44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://huggingface.co/spaces/ysharma/Microsoft_Phi-3-Vision-128k/blob/main/app.py | |
# https://ai.meta.com/blog/llama-4-multimodal-intelligence/ | |
import gradio as gr | |
import base64 | |
from openai import OpenAI | |
from PIL import Image | |
import io | |
from datetime import datetime | |
import random | |
import string | |
# Background of the Chatbot as a placeholder... really smart! | |
PLACEHOLDER = """ | |
<div style="padding: 30px; text-align: center; display: flex; flex-direction: column; align-items: center;"> | |
<img src="https://wwwhatsnew.com/wp-content/uploads/2025/04/llama4-meta-modelos-inteligencia-artificial.png.webp" style="width: 80%; max-width: 550px; height: auto; opacity: 0.55; "> | |
<h1 style="font-size: 28px; margin-bottom: 2px; opacity: 0.55;">LLama 4 Scout</h1> | |
<p style="font-size: 18px; margin-bottom: 2px; opacity: 0.65;">Llama 4 Scout, a 17 billion active parameter model with 16 experts, is the best multimodal model in the world in its class.</p> | |
</div> | |
""" | |
def writehistory(filename,text): | |
""" | |
save a string into a logfile with python file operations | |
filename -> str pathfile/filename | |
text -> str, the text to be written in the file | |
""" | |
with open(f'{filename}', 'a', encoding='utf-8') as f: | |
f.write(text) | |
f.write('\n') | |
f.close() | |
def genRANstring(n): | |
""" | |
n = int number of char to randomize | |
Return -> str, the filename with n random alphanumeric charachters | |
""" | |
N = n | |
res = ''.join(random.choices(string.ascii_uppercase + | |
string.digits, k=N)) | |
print(f'Logfile_{res}.md CREATED') | |
return f'Logfile_{res}.md' | |
# Function to encode the image | |
def encode_image(image_path): | |
with open(image_path, "rb") as image_file: | |
return base64.b64encode(image_file.read()).decode("utf-8") | |
# CSS only to justify center the title | |
mycss = """ | |
#warning {justify-content: center; text-align: center} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment