gamellay / app.py
AstraOS's picture
Update app.py
1765aac verified
raw
history blame
No virus
1.12 kB
import os
import gradio as gr
import modelscope_studio as mgr
def fn(value):
# value includes `text`` and `files``
print(value.text, value.files)
def resolve_assets(relative_path):
# Use the inspect module to get the current file path
import inspect
current_file = inspect.getfile(inspect.currentframe())
return os.path.join(os.path.dirname(current_file), "../../resources",
relative_path)
# Alternatively, you can hardcode the path to the assets folder
# return os.path.join("/content", relative_path)
with gr.Blocks() as demo:
mgr.WaterfallGallery(
value=[
resolve_assets('modelscope.svg'),
# pass a tuple
[resolve_assets('bot.jpeg'), 'bot'],
# pass a dict
{
"image": resolve_assets('user.jpeg'),
"caption": "user",
},
resolve_assets('screen.jpeg'),
],
columns=2,
height=600)
input = mgr.MultimodalInput()
input.change(fn=fn, inputs=[input])
if __name__ == "__main__":
demo.queue().launch()