BarBar288 commited on
Commit
85a5f0e
·
verified ·
1 Parent(s): e8fb7d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -1,9 +1,6 @@
1
- import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
3
- from diffusers import StableDiffusionPipeline
4
- import torch
5
  import os
6
  import logging
 
7
 
8
  # Set up logging
9
  logging.basicConfig(level=logging.INFO)
@@ -13,12 +10,10 @@ logger = logging.getLogger(__name__)
13
  read_token = os.getenv('AccToken')
14
  if not read_token:
15
  raise ValueError("Hugging Face access token not found. Please set the AccToken environment variable.")
16
- from huggingface_hub import login
17
- login(read_token)
18
 
19
- # Set device to GPU if available
20
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
21
- logger.info(f"Device set to use {device}")
22
 
23
  # Define a dictionary of conversational models
24
  conversational_models = {
@@ -130,8 +125,6 @@ def generate_speech(model_name, text):
130
  audio = pipeline(text, speaker_embeddings=speaker_embeddings)
131
  return audio["audio"]
132
 
133
-
134
-
135
  def visual_qa(image, question):
136
  result = visual_qa_pipeline(image, question)
137
  return result["answer"]
 
 
 
 
 
1
  import os
2
  import logging
3
+ from huggingface_hub import login
4
 
5
  # Set up logging
6
  logging.basicConfig(level=logging.INFO)
 
10
  read_token = os.getenv('AccToken')
11
  if not read_token:
12
  raise ValueError("Hugging Face access token not found. Please set the AccToken environment variable.")
13
+ logger.info(f"Hugging Face access token found: {read_token[:5]}...") # Log the first 5 characters for verification
 
14
 
15
+ # Log in to Hugging Face using the token
16
+ login(read_token)
 
17
 
18
  # Define a dictionary of conversational models
19
  conversational_models = {
 
125
  audio = pipeline(text, speaker_embeddings=speaker_embeddings)
126
  return audio["audio"]
127
 
 
 
128
  def visual_qa(image, question):
129
  result = visual_qa_pipeline(image, question)
130
  return result["answer"]