Emmanuel Frimpong Asante commited on
Commit
25fb6a0
·
1 Parent(s): 10cf471

"Update space"

Browse files

Signed-off-by: Emmanuel Frimpong Asante <[email protected]>

README.md CHANGED
@@ -10,4 +10,6 @@ pinned: false
10
  license: mit
11
  ---
12
 
13
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
 
 
10
  license: mit
11
  ---
12
 
13
+ An example chatbot using [Gradio](https://gradio.app), [
14
+ `huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and
15
+ the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
app.py CHANGED
@@ -41,6 +41,7 @@ print("TensorFlow GPU Available:", tf.config.list_physical_devices('GPU'))
41
 
42
  # Set TensorFlow to use mixed precision with available GPU
43
  from tensorflow.keras import mixed_precision
 
44
  if len(tf.config.list_physical_devices('GPU')) > 0:
45
  policy = mixed_precision.Policy('mixed_float16')
46
  mixed_precision.set_global_policy(policy)
 
41
 
42
  # Set TensorFlow to use mixed precision with available GPU
43
  from tensorflow.keras import mixed_precision
44
+
45
  if len(tf.config.list_physical_devices('GPU')) > 0:
46
  policy = mixed_precision.Policy('mixed_float16')
47
  mixed_precision.set_global_policy(policy)
auth/auth_controller.py CHANGED
@@ -9,6 +9,7 @@ from functools import wraps
9
  from config.db import users_collection # Importing the users collection from the database config
10
  from config.settings import SECRET_KEY # Import the secret key from settings
11
 
 
12
  # JWT decorator to protect routes
13
  def token_required(f):
14
  @wraps(f)
@@ -26,6 +27,7 @@ def token_required(f):
26
  except jwt.InvalidTokenError:
27
  return jsonify({'message': 'Token is invalid!'}), 401
28
  return f(current_user, *args, **kwargs)
 
29
  return decorated
30
 
31
 
 
9
  from config.db import users_collection # Importing the users collection from the database config
10
  from config.settings import SECRET_KEY # Import the secret key from settings
11
 
12
+
13
  # JWT decorator to protect routes
14
  def token_required(f):
15
  @wraps(f)
 
27
  except jwt.InvalidTokenError:
28
  return jsonify({'message': 'Token is invalid!'}), 401
29
  return f(current_user, *args, **kwargs)
30
+
31
  return decorated
32
 
33
 
auth/auth_routes.py CHANGED
@@ -7,6 +7,7 @@ from flask import jsonify
7
  # Create a Blueprint for auth-related routes
8
  auth_bp = Blueprint('auth', __name__)
9
 
 
10
  # Define the routes
11
 
12
  @auth_bp.route('/register', methods=['POST'])
 
7
  # Create a Blueprint for auth-related routes
8
  auth_bp = Blueprint('auth', __name__)
9
 
10
+
11
  # Define the routes
12
 
13
  @auth_bp.route('/register', methods=['POST'])
routes/api.py CHANGED
@@ -10,53 +10,65 @@ from controllers.data_logging import log_user_action
10
  # Create a Blueprint for the API routes
11
  api_bp = Blueprint('api', __name__)
12
 
 
13
  # Health Management Routes
14
  @api_bp.route('/detect-disease', methods=['POST'])
15
  def detect_disease_route():
16
  return detect_and_log_disease()
17
 
 
18
  @api_bp.route('/health-record/<record_id>', methods=['GET'])
19
  def get_health_record_route(record_id):
20
  return get_health_record(record_id)
21
 
 
22
  @api_bp.route('/health-records/<user_id>', methods=['GET'])
23
  def get_health_records_for_user_route(user_id):
24
  return get_health_records_for_user(user_id)
25
 
 
26
  # Inventory Management Routes
27
  @api_bp.route('/add-inventory-item', methods=['POST'])
28
  def add_inventory_item_route():
29
  return add_inventory_item()
30
 
 
31
  @api_bp.route('/update-inventory-item', methods=['PUT'])
32
  def update_inventory_item_route():
33
  return update_inventory_item_by_id()
34
 
 
35
  @api_bp.route('/inventory-item/<item_id>', methods=['GET'])
36
  def get_inventory_item_route(item_id):
37
  return get_inventory_by_id(item_id)
38
 
 
39
  @api_bp.route('/inventory', methods=['GET'])
40
  def get_all_inventory_route():
41
  return get_all_inventory()
42
 
 
43
  # Assistant Usage Tracking Routes
44
  @api_bp.route('/log-usage', methods=['POST'])
45
  def log_usage_route():
46
  return log_usage()
47
 
 
48
  @api_bp.route('/usage/<user_id>', methods=['GET'])
49
  def get_usage_for_user_route(user_id):
50
  return get_usage_for_user(user_id)
51
 
 
52
  @api_bp.route('/manager-usage/<manager_id>', methods=['GET'])
53
  def get_usage_for_manager_route(manager_id):
54
  return get_usage_for_manager(manager_id)
55
 
 
56
  @api_bp.route('/usage-type/<interaction_type>', methods=['GET'])
57
  def get_usage_by_type_route(interaction_type):
58
  return get_usage_by_type(interaction_type)
59
 
 
60
  # User Action Logging Route
61
  @api_bp.route('/log-user-action', methods=['POST'])
62
  def log_user_action_route():
 
10
  # Create a Blueprint for the API routes
11
  api_bp = Blueprint('api', __name__)
12
 
13
+
14
  # Health Management Routes
15
  @api_bp.route('/detect-disease', methods=['POST'])
16
  def detect_disease_route():
17
  return detect_and_log_disease()
18
 
19
+
20
  @api_bp.route('/health-record/<record_id>', methods=['GET'])
21
  def get_health_record_route(record_id):
22
  return get_health_record(record_id)
23
 
24
+
25
  @api_bp.route('/health-records/<user_id>', methods=['GET'])
26
  def get_health_records_for_user_route(user_id):
27
  return get_health_records_for_user(user_id)
28
 
29
+
30
  # Inventory Management Routes
31
  @api_bp.route('/add-inventory-item', methods=['POST'])
32
  def add_inventory_item_route():
33
  return add_inventory_item()
34
 
35
+
36
  @api_bp.route('/update-inventory-item', methods=['PUT'])
37
  def update_inventory_item_route():
38
  return update_inventory_item_by_id()
39
 
40
+
41
  @api_bp.route('/inventory-item/<item_id>', methods=['GET'])
42
  def get_inventory_item_route(item_id):
43
  return get_inventory_by_id(item_id)
44
 
45
+
46
  @api_bp.route('/inventory', methods=['GET'])
47
  def get_all_inventory_route():
48
  return get_all_inventory()
49
 
50
+
51
  # Assistant Usage Tracking Routes
52
  @api_bp.route('/log-usage', methods=['POST'])
53
  def log_usage_route():
54
  return log_usage()
55
 
56
+
57
  @api_bp.route('/usage/<user_id>', methods=['GET'])
58
  def get_usage_for_user_route(user_id):
59
  return get_usage_for_user(user_id)
60
 
61
+
62
  @api_bp.route('/manager-usage/<manager_id>', methods=['GET'])
63
  def get_usage_for_manager_route(manager_id):
64
  return get_usage_for_manager(manager_id)
65
 
66
+
67
  @api_bp.route('/usage-type/<interaction_type>', methods=['GET'])
68
  def get_usage_by_type_route(interaction_type):
69
  return get_usage_by_type(interaction_type)
70
 
71
+
72
  # User Action Logging Route
73
  @api_bp.route('/log-user-action', methods=['POST'])
74
  def log_user_action_route():
routes/data_logging_routes.py CHANGED
@@ -13,6 +13,7 @@ from controllers.data_logging import (
13
  # Create a Blueprint for the data logging routes
14
  data_logging_bp = Blueprint('data_logging', __name__)
15
 
 
16
  # Route to log user actions
17
  @data_logging_bp.route('/log-user-action', methods=['POST'])
18
  def log_user_action_route():
 
13
  # Create a Blueprint for the data logging routes
14
  data_logging_bp = Blueprint('data_logging', __name__)
15
 
16
+
17
  # Route to log user actions
18
  @data_logging_bp.route('/log-user-action', methods=['POST'])
19
  def log_user_action_route():
routes/health_routes.py CHANGED
@@ -6,6 +6,7 @@ from controllers.health_management import detect_and_log_disease, get_health_rec
6
  # Create a Blueprint for the health-related routes
7
  health_bp = Blueprint('health', __name__)
8
 
 
9
  # Route to detect disease and log the health record
10
  @health_bp.route('/detect-disease', methods=['POST'])
11
  def detect_disease_route():
 
6
  # Create a Blueprint for the health-related routes
7
  health_bp = Blueprint('health', __name__)
8
 
9
+
10
  # Route to detect disease and log the health record
11
  @health_bp.route('/detect-disease', methods=['POST'])
12
  def detect_disease_route():
routes/inventory_routes.py CHANGED
@@ -12,6 +12,7 @@ from controllers.inventory import (
12
  # Create a Blueprint for the inventory-related routes
13
  inventory_bp = Blueprint('inventory', __name__)
14
 
 
15
  # Route to add a new inventory item
16
  @inventory_bp.route('/add-inventory-item', methods=['POST'])
17
  def add_inventory_item_route():
 
12
  # Create a Blueprint for the inventory-related routes
13
  inventory_bp = Blueprint('inventory', __name__)
14
 
15
+
16
  # Route to add a new inventory item
17
  @inventory_bp.route('/add-inventory-item', methods=['POST'])
18
  def add_inventory_item_route():
services/disease_detection.py CHANGED
@@ -29,6 +29,7 @@ recommend = {
29
  3: 'Ponston' # Treatment for Salmonella
30
  }
31
 
 
32
  class PoultryFarmBot:
33
  def __init__(self, db):
34
  """
 
29
  3: 'Ponston' # Treatment for Salmonella
30
  }
31
 
32
+
33
  class PoultryFarmBot:
34
  def __init__(self, db):
35
  """
services/llama_service.py CHANGED
@@ -5,8 +5,8 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
5
  # Load Llama model and tokenizer for text generation
6
 
7
 
8
- tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-8B")
9
- model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-8B")
10
 
11
  # Ensure the tokenizer has a padding token; if not, add a new padding token
12
  if tokenizer.pad_token is None:
 
5
  # Load Llama model and tokenizer for text generation
6
 
7
 
8
+ tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.1-8B")
9
+ model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.1-8B")
10
 
11
  # Ensure the tokenizer has a padding token; if not, add a new padding token
12
  if tokenizer.pad_token is None:
training/resnet-18-model-for-poultry-disease-classification.ipynb CHANGED
The diff for this file is too large to render. See raw diff