# Project structure:
# files/
# ├── weights/
# │ └── checkpoint.pt
# ├── utils/
# │ └── loader.py
# ├── src/
# │ └── my_fal_app.py
# │ ├── data_processing/
# │ │ ├── __init__.py
# │ │ └── preprocessor.py
# │ └── models/
# │ ├── __init__.py
# │ └── neural_net.py
class MyApp(fal.App):
# Set context to the `files` directory (parent of src/)
app_files_context_dir = "../"
app_files = [
"src/data_processing",
"src/models",
"weights",
"utils",
]
requirements = ["torch", "numpy"]
@fal.endpoint("/predict")
def predict(self, input: MyInput) -> MyOutput:
# Import modules relative to your app file location
from data_processing.preprocessor import clean_data
from models.neural_net import NeuralNetwork
from utils.loader import load
# Access files with relative paths, just like locally
cleaned_input = clean_data(input.raw_data)
model = NeuralNetwork()
load(model, "../weights/checkpoint.pt")
prediction = model.forward(cleaned_input)
return MyOutput(result=prediction)