本教程向您展示瞭如何構建類似於Microsoft的What-Dog AI,但使用Diffbot的Image API,該教程向您展示瞭如何構建狗品種標識符。 整個應用程序少於100行代碼和利用IMGUR以託管以最大程度地降低成本。
密鑰功能:
>使用簡單的圖像上傳表格和PHP進行處理。 > difbot的圖像API分析上載的圖像,並根據已確定的標籤返回建議。
。- 雖然不完美,但最終的應用程序展示了現代AI在圖像識別方面的可訪問性和潛力。
- 入門:
difbot帳戶:從diffbot.com獲取免費的14天API代幣。
- >
- 作曲家設置:使用以下 安裝必要的庫:
-
composer.json
{ "require": { "swader/diffbot-php-client": "^2", "php-http/guzzle6-adapter": "^1.0" }, "minimum-stability": "dev", "prefer-stable": true, "require-dev": { "symfony/var-dumper": "^3.0" } }> imgur帳戶:
<code>Run `composer install`. The `minimum-stability` setting accommodates a beta dependency.</code>>創建一個IMGUR帳戶並獲取匿名映像上傳的客戶ID。
-
代碼結構(index.php):
> 核心邏輯位於
函數(輔助功能):
代碼使用輔助功能(未顯示)為每個建議的品種創建指向Bing Image搜索結果的鏈接。
index.php
<?php require 'vendor/autoload.php'; $token = 'YOUR_DIFFBOT_TOKEN'; // Replace with your Diffbot token $imgur_client = 'YOUR_IMGUR_CLIENT_ID'; // Replace with your Imgur Client ID if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle image upload (using $_FILES) or URL submission (using $_POST['url']) // ... (Image upload to Imgur using Guzzle, obtaining the image URL) ... if (!isset($url) || empty($url)) { die("Image upload or URL submission failed."); } $diffbot = new Swader\Diffbot\Diffbot($token); $imageDetails = $diffbot->createImageAPI($url)->call(); $tags = $imageDetails->getTags(); echo "<img src=\"{$url}\" style="max-width:90%"500\" alt="在100行代碼中構建Microsoft的What-Dog AI" ></img>"; if (empty($tags)) { echo "<h4 id="No-breed-identified">No breed identified.</h4>"; } else { echo "<h4 id="Suggested-Breed-s">Suggested Breed(s):</h4>"; foreach ($tags as $tag) { echo "- <a href=\"https://www.bing.com/images/search?q=" . urlencode($tag['label']) . "\" target=\"_blank\">" . $tag['label'] . "</a><br>"; } } } ?> <!-- HTML form for image upload or URL input -->該教程包括幾個測試圖像及其結果,強調了品種識別的成功和失敗。 準確性與微軟的What-Dog AI相媲美,證明了使用DiffBot構建類似應用的可行性。
結論:
>本教程展示了將AI驅動圖像分析集成到簡單Web應用程序中的易用性。儘管準確性並不完美,但它突出了隨時可用的API來構建強大的圖像識別功能的潛力。 切記用自己的佔位符令牌和ID替換。
以上是在100行代碼中構建Microsoft的What-Dog AI的詳細內容。更多資訊請關注PHP中文網其他相關文章!

phpisusedforsendendemailsduetoitsignegrationwithservermailservicesand andexternalsmtpproviders,自動化intifications andMarketingCampaigns.1)設置設置yourphpenvenvironnvironnvironmentwithaweberswithawebserverserververandphp,確保themailfunctionisenabled.2)useabasicscruct

發送電子郵件的最佳方法是使用PHPMailer庫。 1)使用mail()函數簡單但不可靠,可能導致郵件進入垃圾郵件或無法送達。 2)PHPMailer提供更好的控制和可靠性,支持HTML郵件、附件和SMTP認證。 3)確保正確配置SMTP設置並使用加密(如STARTTLS或SSL/TLS)以增強安全性。 4)對於大量郵件,考慮使用郵件隊列系統來優化性能。

CustomHeadersheadersandAdvancedFeaturesInphpeMailenHanceFunctionalityAndreliability.1)CustomHeadersheadersheadersaddmetadatatatatataatafortrackingandCategorization.2)htmlemailsallowformattingandttinganditive.3)attachmentscanmentscanmentscanbesmentscanbestmentscanbesentscanbesentingslibrarieslibrarieslibrariesliblarikelikephpmailer.4)smtppapapairatienticationaltication enterticationallimpr

使用PHP和SMTP發送郵件可以通過PHPMailer庫實現。 1)安裝並配置PHPMailer,2)設置SMTP服務器細節,3)定義郵件內容,4)發送郵件並處理錯誤。使用此方法可以確保郵件的可靠性和安全性。

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

使用依賴注入(DI)的原因是它促進了代碼的松耦合、可測試性和可維護性。 1)使用構造函數注入依賴,2)避免使用服務定位器,3)利用依賴注入容器管理依賴,4)通過注入依賴提高測試性,5)避免過度注入依賴,6)考慮DI對性能的影響。

phpperformancetuningiscialbecapeitenhancesspeedandeffice,whatevitalforwebapplications.1)cachingwithapcureduccureducesdatabaseloadprovesrovessetimes.2)優化

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。