File size: 1,494 Bytes
4f48282
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47



#script_execution_control

# This checks whether the current script is being run as the main program or if it is being imported as a module into another script.
# When a Python script is executed, Python sets the special variable __name__ to "__main__" for that script.
# If the script is imported as a module into another script, __name__ is set to the name of the module (e.g., the filename without the .py extension).
# Prevents Unintended Execution:
# If you import this script as a module in another script, the code inside the if __name__ == "__main__": block will not run. This prevents unintended execution of the main() function when the script is imported.

if __name__ == "__main__":
    main()



# HUGGING FACE LOGIN

login(token=hf_token)


# MODAL SECRETS
#Here's how you can pass huggingface-token to your Modal function:

import os
import modal

app = modal.App()

@app.function(secrets=[modal.Secret.from_name("huggingface-token")])
def f():
    print(os.environ["HF_TOKEN"])


#CONVERT PIL IMGS 

    # Convert PIL image to NumPy array
    numpy_array = np.array(image)
    print(numpy_array.shape)  # Should print (352, 640, 3) for height, width, channels
    # Convert PIL image to NumPy array
    numpy_array = np.array(pil_image)
    # Convert RGB to BGR for OpenCV
    opencv_image = cv2.cvtColor(numpy_array, cv2.COLOR_RGB2BGR)
    # Now you can use it with OpenCV functions
    cv2.imshow("OpenCV Image", opencv_image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()