Spaces:
Running
on
Zero
Running
on
Zero
import subprocess | |
import sys | |
def install_packages(): | |
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip']) | |
with open('requirements.txt') as f: | |
packages = f.read().splitlines() | |
for package in packages: | |
if package and not package.startswith('#'): | |
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package]) | |
if __name__ == "__main__": | |
print("Installing required packages...") | |
install_packages() | |
import gradio as gr | |
import torch | |
from transformers import AutoProcessor | |
def process_handwriting(image): | |
if image is None: | |
return "กรุณาอัพโหลดรูปภาพ" | |
return f"ทดสอบระบบ: Torch version: {torch.__version__}, Transformers installed" | |
demo = gr.Interface( | |
fn=process_handwriting, | |
inputs=gr.Image(type="pil", label="อัพโหลดรูปภาพ"), | |
outputs=gr.Textbox(label="ผลลัพธ์"), | |
title="Test Installation", | |
description="ทดสอบการติดตั้ง libraries" | |
) | |
demo.launch() |