發表文章

目前顯示的是 3月, 2025的文章

Gradio筆記1_不用碰到js,css也能藉由短短幾行python code產生網站介面

圖片
  pip install gradio 此時會自動安裝一堆的相依套件 預覽透過7860這個port開啟 http://127.0.0.1:7860 上述執行都是用直接python 去RUN的方式,當我們調整程式要Reload時候都要中斷再重新RUN十分麻煩。可以透過下gradio指令的方式來快速讓他讀取到存入的變更,並自動刷新網頁且不用中斷。 gradio my_gradio.py --demo-name=web_demo gradio {你所指定的.py檔案名稱} --demo-name={你這邊要launch網站的變數別名} 當然假設今天想將demo網頁分享給其他人,也完全不需要花時間搞捨麼租用主機 跟架設虛擬主機等等步驟,只需要調整.launch() 括號後面參數設置為share=True即可分享跨網域給全世界,只要這隻應用仍然開著RUN的話。 測試程式碼 import gradio as gr def greet (Name,is_morning,temperature): msg = "Good morning" if is_morning else "Good afternoon" greeting = f "{msg} {Name}. It is {temperature} 攝氏溫度." celsius = (temperature - 32 ) * 5 / 9 return greeting, round (celsius, 2 ) #必要三個參數:輸入/輸出 web_demo = gr.Interface(fn=greet, # 指定function不指定就給None inputs=[ "text" , "checkbox" ,gr.Slider( 0 , 60 )], outputs=[ "text" , "number" ],clear_btn= None ,submit_btn= "送出" , ...

MySQL_ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)_重置root密碼

圖片
  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) (using password: NO) 表示嘗試連接時沒有提供密碼。 (using password: YES) 表示嘗試連接時提供了密碼。 我這邊起初密碼是rootroot 如果出現的是這種錯誤,絕大部分偏向是更改過密碼但忘記了用上一次記憶中的密碼。 ERROR 1045 (28000): Access denied for user 'root'@'localhost'  (using password: YES) 表示我們嘗試以root用戶連接MySQL資料庫時提供的密碼不正確。 重置root密碼 Step1.開啟Windows「服務」管理工具(可以在開始菜單中搜索「services.msc」),找到MySQL服務,並停止它。 指令方式: taskkill /F /IM mysqld.exe 以下是介面方式: 當你關閉MySQL服務後,3306服務此時就沒有相關服務在使用了。 Step2.在C槽新增一個mysql-init.txt 內容如下 ALTER USER 'root'@'localhost' IDENTIFIED BY '你想更換的新密碼'; Step3.用cmd並以系統管理員來啟動 下以下指令 mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\\mysql-init.txt" --console Step4.另外去開Command Line Client確認是否可用新密碼登入 確認密碼已更改成新的了 Step5.將剛開起的cmd都關閉後,再重啟MySQL服務即可。 此時你用新的密碼來cmd登也可以成功。 Ref: H...

探索式資料分析EDA_皮爾森積差相關係數(波士頓房價)_熱度圖&散點圖

圖片
  這邊要先確保sklearn使用版本要是1.1.3版本(之後版本都移除波士頓房價的toy dataset了) 然後numpy不能到2.x版本 要是1.26.4 https://stackoverflow.com/questions/78634235/numpy-dtype-size-changed-may-indicate-binary-incompatibility-expected-96-from Attribute Information (in order):         - CRIM     per capita crime rate by town         - ZN       proportion of residential land zoned for lots over 25,000 sq.ft.         - INDUS    proportion of non-retail business acres per town         - CHAS     Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)         - NOX      nitric oxides concentration (parts per 10 million)         - RM       average number of rooms per dwelling         - AGE      proportion of owner-occupied units built prior to 1940     ...