Spaces:
No application file
No application file
Upload 3 files
Browse files- app.py +32 -0
- requirements.txt +7 -0
- src/deploy/update_space.py +19 -0
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from src.model.vision_model import ChartVisionModel
|
| 3 |
+
import ollama
|
| 4 |
+
|
| 5 |
+
def analyze_chart(image):
|
| 6 |
+
client = ollama.Client()
|
| 7 |
+
|
| 8 |
+
system_prompt = """Analyze this technical chart and provide:
|
| 9 |
+
1. Pattern Recognition (Support/Resistance, Trends)
|
| 10 |
+
2. Technical Indicators Analysis
|
| 11 |
+
3. Price Action Analysis
|
| 12 |
+
4. Volume Analysis
|
| 13 |
+
5. Future Price Predictions
|
| 14 |
+
Format the response in clear sections."""
|
| 15 |
+
|
| 16 |
+
response = client.generate(
|
| 17 |
+
model="llama3.2-vision:latest",
|
| 18 |
+
prompt=system_prompt,
|
| 19 |
+
images=[image]
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
return response
|
| 23 |
+
|
| 24 |
+
interface = gr.Interface(
|
| 25 |
+
fn=analyze_chart,
|
| 26 |
+
inputs=gr.Image(type="pil"),
|
| 27 |
+
outputs=gr.Textbox(label="Analysis Results"),
|
| 28 |
+
title="Technical Chart Analysis",
|
| 29 |
+
description="Upload a chart image for comprehensive technical analysis"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.0.0
|
| 2 |
+
torch>=2.0.0
|
| 3 |
+
transformers>=4.30.0
|
| 4 |
+
python-ollama>=0.1.0
|
| 5 |
+
Pillow>=10.0.0
|
| 6 |
+
huggingface-hub>=0.19.0
|
| 7 |
+
python-dotenv>=1.0.0
|
src/deploy/update_space.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import HfApi, login
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
def update_space_repo():
|
| 6 |
+
load_dotenv()
|
| 7 |
+
api = HfApi()
|
| 8 |
+
login() # Will use HF_TOKEN from environment
|
| 9 |
+
|
| 10 |
+
api.upload_folder(
|
| 11 |
+
folder_path=".",
|
| 12 |
+
repo_id="tmmdev/chart-analyzer",
|
| 13 |
+
repo_type="space"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
print("✨ Space updated successfully!")
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
update_space_repo()
|