Spaces:
No application file
No application file
Delete app.py
Browse files
app.py
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import sys
|
3 |
-
import gradio as gr
|
4 |
-
from PIL import Image
|
5 |
-
import ollama
|
6 |
-
from lightweight_charts import Chart
|
7 |
-
|
8 |
-
# Add ai-analyzer's src to path
|
9 |
-
current_dir = os.path.dirname(os.path.abspath(__file__))
|
10 |
-
sys.path.insert(0, current_dir)
|
11 |
-
|
12 |
-
# Initialize both AI models
|
13 |
-
vision_client = ollama.Client()
|
14 |
-
code_client = ollama.Client()
|
15 |
-
|
16 |
-
VISION_MODEL = "llama3.2-vision:latest"
|
17 |
-
CODE_MODEL = "codellama:latest"
|
18 |
-
|
19 |
-
# Local imports
|
20 |
-
from src.model.vision_model import ChartVisionModel
|
21 |
-
from src.model.chart_generator import ChartGeneratorModel
|
22 |
-
from src.analysis.chart_processor import ChartProcessor
|
23 |
-
from src.analysis.pattern_generator import PatternGenerator
|
24 |
-
from src.analysis.indicator_generator import IndicatorGenerator
|
25 |
-
from src.analysis.chart_analyzer import ChartAnalyzer
|
26 |
-
from src.data.market_data import MarketData
|
27 |
-
|
28 |
-
def analyze_full_chart(chart_image, symbol):
|
29 |
-
# Vision analysis using ChartVisionModel
|
30 |
-
vision_model = ChartVisionModel()
|
31 |
-
vision_analysis = vision_model.analyze_chart(chart_image)
|
32 |
-
|
33 |
-
# Chart generation using ChartGeneratorModel
|
34 |
-
chart_generator = ChartGeneratorModel()
|
35 |
-
|
36 |
-
market_data = MarketData()
|
37 |
-
historical_data = market_data.fetch_ohlcv(symbol)
|
38 |
-
|
39 |
-
# Pattern Generation
|
40 |
-
pattern_gen = PatternGenerator()
|
41 |
-
pattern_images = pattern_gen.generate_all_patterns(chart_image, historical_data)
|
42 |
-
|
43 |
-
# Indicator Generation
|
44 |
-
indicator_gen = IndicatorGenerator()
|
45 |
-
indicator_charts = indicator_gen.generate_all_indicators(historical_data)
|
46 |
-
|
47 |
-
# Process chart
|
48 |
-
processor = ChartProcessor()
|
49 |
-
processed_results = processor.process_chart(chart_image)
|
50 |
-
|
51 |
-
# Full chart analysis
|
52 |
-
analyzer = ChartAnalyzer()
|
53 |
-
analysis_results = analyzer.analyze_full(
|
54 |
-
chart_image=chart_image,
|
55 |
-
pattern_images=pattern_images,
|
56 |
-
indicator_charts=indicator_charts,
|
57 |
-
historical_data=historical_data
|
58 |
-
)
|
59 |
-
|
60 |
-
return {
|
61 |
-
'pattern_analysis': analysis_results.patterns,
|
62 |
-
'indicator_analysis': analysis_results.indicators,
|
63 |
-
'predictions': analysis_results.predictions,
|
64 |
-
'interactive_charts': indicator_charts,
|
65 |
-
'chart_analysis': processed_results,
|
66 |
-
'vision_results': vision_analysis
|
67 |
-
}
|
68 |
-
|
69 |
-
interface = gr.Interface(
|
70 |
-
fn=analyze_full_chart,
|
71 |
-
inputs=[
|
72 |
-
gr.Image(type="pil", label="Chart Image"),
|
73 |
-
gr.Textbox(label="Symbol")
|
74 |
-
],
|
75 |
-
outputs=[
|
76 |
-
gr.Gallery(label="Pattern Overlays"),
|
77 |
-
gr.Gallery(label="Indicator Charts"),
|
78 |
-
gr.JSON(label="Analysis Results"),
|
79 |
-
gr.Plot(label="Interactive Indicators")
|
80 |
-
]
|
81 |
-
)
|
82 |
-
|
83 |
-
if __name__ == "__main__":
|
84 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|